tj/react-enroute

New props in Router will not re-render children with new props.

wmira opened this issue · 2 comments

wmira commented

the closure of props from this function https://github.com/tj/react-enroute/blob/master/index.js#L45 seems to be causing issue and not passing new props to children on subsequent renders.

Something like below fixes the issue:

const render = (params, renderProps) => {
       const finalProps = { ...this.props, ...renderProps, location, params };
       const children = React.createElement(component, finalProps);
      return parent ? parent.render(params, { children }) : children;
}

I'm getting the same issue which makes this router almost useless. The state props are not updated while navigating.

So the state can be used as an initial state only at the moment.

tj commented

Sorry, missed this it didn't show up in my notifications!