goatslacker/alt

Child components fail when using Render.withData

Open

#354 aperta il 25 giu 2015

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)JavaScript (337 fork)batch import
bughelp wanted

Metriche repository

Star
 (3451 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

Failing test case:

import Alt from 'alt'
import * as Render from 'alt/utils/Render'

const alt = new Alt()

import React, { Component } from 'react'

const actions = alt.generateActions('success', 'fail')

const Source = {
  things: {
    remote(_, x) {
      return Promise.resolve(x)
    },

    success: actions.success,
    error: actions.fail
  }
}

const store = alt.createStore(class {
  constructor() {
    this.registerAsync(Source)
    this.bindActions(actions)

    this.caca = null
  }

  success(x) {
    console.log('ok')
    this.caca = x
  }

  fail() {
    console.log('shit')
  }
}, 'store')


const App = Render.withData(() => {
  return store.things(1)
}, class extends Component {
  static displayName = 'App'

  constructor() {
    super()
    console.log(1)
  }

  render() {
    console.log('RENDERING')
    return (
      <div>
        <div>Hello World {store.getState().caca}</div>
        <Child />
      </div>
    )
  }
})

const Child = Render.withData(() => {
  console.log('WHY AM I NOT HERE?')
  return store.things(2)
}, class extends Component {
  static displayName = 'Child'

  constructor() {
    super()
    console.log(2)
  }

  render() {
    return <div>Wtf {store.getState().caca}</div>
  }
})

Render.toString(App, {}).then((markup) => {
  console.log('@', markup)
}).catch((err) => {
  console.log('uhoh', err)
})


Guida contributor