-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
added applyRouterMiddleware #3327
Conversation
c8da3ee
to
b8a7baf
Compare
import RouterContext from './RouterContext' | ||
|
||
export default (...middlewares) => { | ||
const withContextContainer = middlewares.filter( |
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.
Slightly more optimized to write this as
middlewares.map(m => m.renderRouteComponent).filter(f => f)
and then skip destructuring in the reduce callback below.
What do you think of renaming the callbacks to:
They're not constrained to be containers – e.g. renderRouteComponent: child => cloneElement(child, { bazInjected }) |
b8a7baf
to
58e2c9a
Compare
@@ -2,9 +2,11 @@ | |||
> Unreleased | |||
|
|||
- **Minor:** Speed up checking index path active status ([#3313]) | |||
- **Minor:** Added `applyRouterMiddleware` ([#3327]) |
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.
This should be Feature:, I think.
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.
done
LGTM. |
547a4d1
to
e51310b
Compare
e51310b
to
28f449f
Compare
So, if I had a custom render previously, I would have to inject the enhanced RouterContext, right? Kind of as following: const RouterContextFactory = applyRouterMiddleware(useFoo());
<Router
render={renderProps =>
<Fetcher {...renderProps}>
{RouterContextFactory(renderProps)}
</Fetcher>
}
/> |
@ryanflorence thanks for adding this. Do you know if this ended up being documentet anywhere? Could not find anything in the official docs or in the referenced @knowbody docs. Would you want a PR to either? |
I'll add some docs in @knowbody's new docs site thing, but here's the quick version: