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

Routes is not passing subsequent child prop values to route handler using React.renderComponent #268

Closed
Zenwolf opened this issue Sep 7, 2014 · 2 comments

Comments

@Zenwolf
Copy link

Zenwolf commented Sep 7, 2014

I have the <Routes> component as my top-level React component. It has a custom child property, like this:

React.renderComponent(
      <Routes location="history">
        <Route handler={ MyApp }
               myProps={ myProps }>

          <Route name="foo"
                 path="/foo/:fooId"
                 handler={ Foo } />

          <Route name="bar"
                 path="/bar/:barId"
                 handler={ Bar } />
        </Route>
      </Routes>,
      document.getElementById('container')
    );

However, when subsequent external data changes, and I call React.renderComponent again with a new value for myProps, the MyApp only ever receives the very first myProps value, and never any updated value (debugged in MyApp#componentWillReceiveProps()). I am not sure why the value would not get passed through the router, but I can't find any other explanation after several hours of debugging.

@trevex
Copy link

trevex commented Sep 24, 2014

Same problem here...

@ryanflorence
Copy link
Member

The router is not designed to be called multiple times from React.renderComponent.

However, I believe the following work will get you what you need:

tl;dr: we will give you a chance to determine the props for a route before we activate it. Its not the same as just rendering <Routes/> over and over, but I think it meets the same use-case.

Have a read through that stuff, if it doesn't look like it helps, please make some noise and I'll reopen this.

For now, you'll need some way to subscribe to that those data changes in your handlers to get the new data.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants