goatslacker/alt

Child components fail when using Render.withData

Aberta

#354 aberto em 25 de jun. de 2015

 (2 comentários) (0 reação) (0 responsável)JavaScript (313 forks)batch import
bughelp wanted

Métricas do repositório

Stars
 (3.427 estrelas)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

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)
})


Guia do colaborador