ryanflorence / react-router-relative-links

MIT License
78 stars 10 forks source link

Using React.cloneElement along with react-router-relative-links? #2

Open mvaivre opened 8 years ago

mvaivre commented 8 years ago

First of all, thanks for this very useful middleware! Don't know if it's better to create an issue here or in the react-router repo, but anyway:

It seems that using cloneElement to pass more props to this.props.children is not working when a middleware like react-router-relative-links is used.

The new layer RelativeLinksContainer that uses a createElement method to render the final component seems to prevent us from modifying the props set.

jedwards1211 commented 8 years ago

you could put your own middleware in (before useRelativeLinks()) that does the cloning

jedwards1211 commented 8 years ago

Actually I've run into this again, now I realize, RelativeLinksContainer should be transparently passing extra props along to its children, as should any other middleware containers, so that everything behaves the same as if the unwrapped child route component is cloned.