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
Pass props to <Location /> or <Page /> from parent component #104
Comments
So you want to pass props to the upper-level Router component (Pages or Locations) and have it passed down to each child? At this time props on the top component are sent to its component (usually React.DOM.div in the case of Locations, or React.DOM.body in the case of Pages). There is not support for sending props to all child routes, although this could be nice to have.
|
That's correct. My app is only using one level of
However props still aren't passed; for the URL
So the URL attributes are passed in as props just fine, but actual props aren't. This would be as simple as merging two objects, wouldn't it? I think passing down props through locations should be up to the user to do, especially as |
I've just had a look at some tickets in RRC. It looks like passing props down would make doing stuff like setting |
Now that this project is stable again and on React 0.12, it would be a great time to give this a shot. I won't have the time in the next few days, but take a look at Router.js - the function |
Any updates or thought on this? |
@MPiccinato This is now in |
Awesome, thanks! |
This is with the React 0.12 branch of RRC. I haven't tried it with the current release of RRC.
I want to pass props down to a page view, but I can't seem to pass them further than the
<Pages />
component; if Iconsole.log
a handler's props, I just get whatever default props were defined on it, not props passed down. FWIW the route parameters are passed down correctly.I think I could use a React factory to wrap my handlers and pass props in that way, but I'd very much like to keep the nice clean syntax as seen below. Is this a bug in RRC, or is it simply not supported?
I have a
<Router />
with routes in it:And an
<App />
which contains my app:I'm using the React 0.12 spread operator
{...this.props}
to pass down all the props to the router (using the 0.12 branch of RRC). This by itself works fine.The text was updated successfully, but these errors were encountered: