Skip to content

Commit 18e8f60

Browse files
committed
Add additional props passing method
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.
1 parent 82896c3 commit 18e8f60

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/Troubleshooting.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,10 @@ There are multiple ways to do this depending on what you want to do. You can:
7070

7171
- Define additional values on `<Route>` or the plain route. This will make those values available on `this.props.route` on route components.
7272
- Pass in a `createElement` handler to `<Router>` or `<RouterContext>`. This will allow you to inject additional props into route elements at creation time.
73+
- Pass in a `render` handler to `<Router>` with the result of `applyRouterMiddleware`, using a middleware such as:
74+
```javascript
75+
extraProps => ({
76+
renderRouteComponent: (child) => React.cloneElement(child, extraProps)
77+
})
78+
```
7379
- Define a top-level component above `<Router>` or `<RouterContext>` that exports additional values via `getChildContext`, then access them via context from rendered components.

0 commit comments

Comments
 (0)