I'm just checking if I have language in redux store or not. If I have, I'll save that in my localStorage
, if not I want to navigate to a component call MultiLanguage
.
I used below approach using history
but it's showing mw an error. What is it showing push of undefined
and what could be solution for this?
const history = useHistory();
const language = store.getState().languages.selectedLangauge.language;
console.log("language", language);
if (language) {
localStorage.setItem("language", language);
} else {
history.push("/multilanguage");
}
return (
<div className="font-metropolis_regular">
<Router>
<Route path="/" exact component={Selection} />
<Route path="/login" component={Login} />
<Route path="/home" component={Homepage} />
<Route path="/account" component={Account} />
<Route path="/multilanguage" component={MultiLanguage} />
</Router>
</div>
);