From ef52a99eae6acdc9eb52917e17d125d388ca4eed Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Tue, 10 Oct 2017 17:18:24 -0500 Subject: [PATCH] Add Passing Props Down To React-Router Route as a react til --- README.md | 3 +- ...assing-props-down-to-react-router-route.md | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 react/passing-props-down-to-react-router-route.md diff --git a/README.md b/README.md index d3b12a4..c982f8e 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). For a steady stream of TILs from a variety of rocketeers, checkout [til.hashrocket.com](https://til.hashrocket.com/). -_573 TILs and counting..._ +_574 TILs and counting..._ --- @@ -407,6 +407,7 @@ _573 TILs and counting..._ ### React - [Force A Component To Only Have One Child](react/force-a-component-to-only-have-one-child.md) +- [Passing Props Down To React-Router Route](react/passing-props-down-to-react-router-route.md) ### Ruby diff --git a/react/passing-props-down-to-react-router-route.md b/react/passing-props-down-to-react-router-route.md new file mode 100644 index 0000000..4e51372 --- /dev/null +++ b/react/passing-props-down-to-react-router-route.md @@ -0,0 +1,29 @@ +# Passing Props Down To React-Router Route + +When using [react-router](https://github.com/ReactTraining/react-router), +you'll often use the `component` prop to have a certain component rendered. + +```javascript + +``` + +If, however, you need to pass props down into `MyComponent`, then you'll +want to use the `render` prop with an inline function. + +```javascript + ( + + )} +/> +``` + +The two spread operator statements are essential. They will pass down the +[route +props](https://reacttraining.com/react-router/web/api/Route/Route-props) +that `Route` would have passed down plus the additional set of props that +you want to pass down.