My routes are like
<BrowserRouter>
<App>
<Switch>
<Route path="/:locale?" component={Home}/>
</Switch>
</App>
</BrowserRouter>
App component is
class App extends Component {
componentDidMount() {
if (this.props.match) {
console.log(this.props.match);
}
}
}
I'm getting undefined here. This only works for Home component.
I need some workaround for changing language state according to :locale
for every Route. I don't want to do this manually for every route component.