-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Add additional props passing method #3389
Conversation
- Pass in a `render` handler to `<Router>` with the result of `applyRouterMiddleware`, using a middleware such as: | ||
```javascript | ||
() => ({ | ||
renderRouteComponent: (child, routeComponentProps) => React.cloneElement(child, extraProps) |
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.
extraProps => ({
renderRouteComponent: child => React.cloneElement(child, extraProps)
})
Maybe it's a good idea to mention that you can access the |
That can be covered in other docs. It's not relevant for the purposes of this discussion and will e.g. fail most linting rules. |
- Pass in a `render` handler to `<Router>` with the result of `applyRouterMiddleware`, using a middleware such as: | ||
```javascript | ||
extraProps => ({ | ||
renderRouteComponent: (child, routeComponentProps) => React.cloneElement(child, extraProps) |
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.
Please drop routeComponentProps
here.
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
This solution is an improvement over the `createElement` method in that it passes eslint-plugin-react problem jsx-eslint/eslint-plugin-react#512, and that conceptually, I think a middleware is the place to do these kind of manipulations.
Thanks! |
This solution is an improvement over the
createElement
method in that it passes eslint-plugin-react problem jsx-eslint/eslint-plugin-react#512, and that conceptually, I think a middleware is the place to do these kind of manipulations.