-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
[added] Support custom RoutingContext on Router #2383
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
Conversation
My intention here on the
The code would be something like: const RelayRoutingContext = ({forceFetch, ...props}) => (
<RelayRoutingWrapper {...props} forceFetch={forceFetch}>
<RoutingContext {...props} />
</RelayRoutingWrapper>
)
const RelayRouter = (props) => (
<Router {...props} RoutingContext={RelayRoutingWrapper} />
); The idea is that most users can just use |
Done making trivial tweaks to the new test cases... finally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit) This should be camelCased as routingContext
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me - I've seen people do both for custom component classes depending on the context and don't have a personal preference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose it would be different if the DI here was done via module. But then you wouldn't even have this problem in the first place (you'd have others, but that's a different story...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implicitly I'm sorta re-using the module name here: https://github.com/rackt/react-router/pull/2383/files#diff-1063d4db6b1a5033d4afb74421a91ef4R31
It's not extremely clever, but it saves a tiny amount of typing.
@timdorr Updated with your feedback. I also realized that I have to pass extra props from |
Could you not communicate that information via |
@timdorr I can - however, the only thing I need to override really is just the |
If either of you have a chance, I'd appreciate it if you could have a quick look at the proposed API (i.e. adding a This isn't relevant for 1.0.0, but it'd be helpful to know if this approach seems reasonable. |
Shoot, if we want to drop |
Keep And then lets merge this. |
Squashed, rebased, renamed |
[added] Support custom RoutingContext on Router
Closes #2088
Another attempt at #2376. The tests illustrate the intended usage. I think this is a much less gross API on the React Router side.