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
React component context is not passed down to subroutes #60
Comments
By design, all route handler descriptors are created inside the top-level route's What do you need the context for? I've seen it used in various places, but as you say the API is experimental so I'm not sure we need to support it. |
Whoops, I didn't account for My only use for context is not having to pass down explicitly my <Route handler={FluxApp} flux={flux}>
<Route name="dashboard" handler={Dashboard} flux={flux} />
<Route name="form" handler={Form} flux={flux} />
</Route> vs <Route handler={FluxApp} flux={flux}>
<Route name="dashboard" handler={Dashboard} />
<Route name="form" handler={Form} />
</Route> I'm using fluxxor and currently FluxChildMixin only checks for getFlux: function() {
return this.props.flux || this.context.flux;
} Closing this and hopefully React on their next release enables passing down the context without having to create the child at the parent component being rendered. |
I've been toying with the idea of having a RouteMixin and our Route is simply the mixin implemented into a class. This way you could make your own route: var FluxRoute = React.createClass({
mixins: [RouteMixin],
getInitialProps: function() {
return { flux: flux };
}
}); Then you don't have to pass it to anything:
Seems useful? |
RouteMixin does seem useful |
I got to tinker with RouteMixin in a fork... I like it 👍 ... I prefer it over messing with context till it stabilizes |
What ever happened with this? |
Context is not passed down to subroutes, because the handler component is created outside the rendering component.
Thoughts on having access to
activeRouteHandler
&activeRouteProps
or some function to create the component explicitly?The text was updated successfully, but these errors were encountered: