I found my self working with a react template and route. I am not able to pass props to inner component in order to change page title.
Route are defined as below in the template a I added "title" props for each routes in order to pass to inner components.
const loadable = loader =>
Loadable({
loader,
delay: false,
loading: () => null,
})
const loadableRoutes = {
'/registration': {
component: loadable(() => import('sm-pages/RegistrationPage')),
title : "Registration"
},
'/registrationSuccess': {
component: loadable(() => import('sm-pages/RegistrationPage')),
title : "Registration Success"
},
...
render() {
return (
<ConnectedSwitch>
<Route exact path="/" component={HomePage} />
{Object.keys(loadableRoutes).map(path => {
const { exact, ...props } = loadableRoutes[path]
props.exact = exact === void 0 || exact || false // set true as default
return <Route key={path} path={path} {...props} />
})}
<Route
render={() => (
<Page>
<NotFoundPage />
</Page>
)}
/>
</ConnectedSwitch>
)
}
The template has differents inner components and at some point it render my component as below:
render() {
const { getContentBuffer } = this.context
const { pathName, content } = getContentBuffer()
return isEmpty(content) ? (
<div className="utils__loadingPage" />
) : (
<div className="utils__content">
<Breadcrumb name={pathName} />
{content}
</div>
)
}
I access to props (without success) in my component in this way:
render() {
const props = this.props
return (
<h1>{this.props.title}</h1>
)
}
How I have to change in order to access to title props?
Thanks in advance