ManuelDeLeon / viewmodel-react

Create your React components with view models.
MIT License
24 stars 3 forks source link

params passed to child as props not updating in deferred component #23

Closed wildhart closed 7 years ago

wildhart commented 7 years ago

With react-router, params on the url are passed to the component, e.g:

<Route path="defer/:id" component={Defer} />

If the child component contains another child which is deferred, and passes the params to the child like so:

Defer({     
    render() {
        <Home b="defer: true" id={this.props.params.id}/>
    }
});

When the route changes from defer/foo to defer/bar the value of this.id() inside the home component does not change. Also this.props.id does not change, but this.parent().props.params.id does change.

If you remove the b="defer: true" then they all change as expected.

I've created a repro here: https://github.com/wildhart/viewmodel-react-starter-meteor-ssr/tree/bug_defer_props

ManuelDeLeon commented 7 years ago

I have a fix for it (dunno if it's the fix yet).

In the meantime, is there a way for you to update the router? I get a ton of warnings and errors and it's hard to know if VM is doing something wrong or if it's the router.

wildhart commented 7 years ago

What errors are you getting? Ignore the index route, that has some errors because this.id() is not defined, but on the /defer/foo route I don't get any errors on the client or server. All I get in the client is the warning Warning: Accessing PropTypes via the main React package is deprecated...

I'm using react-router 3.0.5

ManuelDeLeon commented 7 years ago

It was the warnings.

This is fixed with viewmodel-react-plugin v3.0.3. Let me know if you run into any other issues.