score:7

Accepted answer

the props are passed to the render prop method by the route component. you can see this in the react router source code. the props passed by the route component have match, location, history, staticcontext. if you want to use props from the parent component, where you are defining the render props method then you can omit the props argument.

render={() => <about {...props} />}

then you would get the props from the component that contains the route.

the example you have provided doesn't make much sense since that replicates the behaviour that you get by just using the 'component' prop on the route.

https://github.com/reacttraining/react-router/blob/master/packages/react-router/modules/route.js#l120

score:1

you get react router default props while passing props in render method just like if use component instead of using render props which implicitly get all these props match, location, history and staticcontext. and you need to provide props as an argument otherwise it render method won't pass props down to the children because it will consider it undefined.

here is working example for render props in react router: https://codesandbox.io/s/72k8xz669j

score:7

we use route with render props as,

<route path = "/about" component={about} />

or,

<route path = "/about" render= { (props) => <about {...props} } />

the second one is different from the first one in the sense that in the second case, the about component has access to the props coming through the route.

say, for instance, there is a profile component,

<route path="/admin/profile"
       render={ props => (
              <profile tabs= {"valuepassed"} {...props}  />  
        )}
 />

now in profile component, we can access all the props,

this.props.tabs give "valuepasses" in class-based component while props.tabs is used for functional component.

hope this helps.


Related Query

More Query from same tag