Skip to content
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

Merged
merged 1 commit into from Apr 28, 2016
Merged

Add additional props passing method #3389

merged 1 commit into from Apr 28, 2016

Conversation

perrin4869
Copy link
Contributor

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.

- 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)
Copy link
Contributor

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)
})

@perrin4869
Copy link
Contributor Author

Maybe it's a good idea to mention that you can access the route object from routeComponentProps here? Since you could store extra props for specific routes there.

@taion
Copy link
Contributor

taion commented Apr 27, 2016

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop routeComponentProps here.

Copy link
Contributor Author

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.
@taion taion merged commit 34ba72d into remix-run:master Apr 28, 2016
@taion
Copy link
Contributor

taion commented Apr 28, 2016

Thanks!

@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants