Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parent component setState events not triggering tab content re-renders #17

Open
litch opened this issue May 21, 2015 · 1 comment
Open

Comments

@litch
Copy link

litch commented May 21, 2015

I have a page like this:

React.createClass({
  onChange: function() {
    this.setState({
      customer: CustomerStore.getCustomer()
    })
  },

...

  render: function() {
    return (
      <div className="CustomerPage">
        <div id="body">
          <Tabs>  
            <Tabs.Tab title='Balances'><BalancesTab customer={customer} /></Tabs.Tab>
            <Tabs.Tab title='Cards'><CardsTab customer={customer} /></Tabs.Tab>
            <Tabs.Tab title='Loans'><LoansTab customer={customer} /></Tabs.Tab>
          </Tabs>
        </div>
      </div>
    )
  }
})

If I update the CustomerStore with a customer (say via an asynchronous request), it
will not trigger the tab content components to re-render.

I believe that is due to the cloneWithProps call (https://github.com/akiran/react-foundation-apps/blob/master/lib/tabs/index.jsx#L16).

Incidentally, cloneWithProps is now deprecated and it should be React.cloneElement. I'm not able to
make it work even by using that cloneElement, though. I can think of a few workarounds but they all seem
terrible.

Any ideas?

@litch
Copy link
Author

litch commented May 21, 2015

Update - I was able to resolve this by putting key properties on the Tabs.Tab elements:

<Tabs.Tab title='Info' key={"info " + customer.id}>{info}</Tabs.Tab>

It seems a bit wrong to me, because really that should not be doing a key change to force that update, but that seemed to be the best solution for now...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant