rerender component on route change code example
Example: route to change a part of component
<Route
exact
path="/"
render={props => (
<Page {...props} component={Index} title="Index Page" />
)}
/>
<Route
path="/about"
render={props => (
<Page {...props} component={About} title="About Page" />
)}
/>
import React from "react"
class Page extends React.Component {
componentDidMount() {
document.title = this.props.title
}
render() {
const PageComponent = this.props.component
return (
<PageComponent />
)
}
}
export default Page