Hello
I need that depending on a variable stored in memory, when entering the site or the application, that is, when the url = “/”, it goes to one of two specific urls
The problem with the code that I have raised is that it does not show any url, everything is blank.
Why is that? It is because App should not have a return statment?
Depending if isReg equals true path="/" must route to /Registro and if isReg is false must route to /home
const App: React.FC = () => {
const [isReg, setIsReg] = useState(false);
useEffect(() => {
if(getItem("isRegistered")==null){
console.log(getItem("isRegistered"));
setIsReg(true);
}
else{
setIsReg(false);
}
}, []);
if(isReg){
return (
<IonApp>
<IonReactRouter>
<IonSplitPane contentId="main" when="(min-width: 4096px)">
<Menu />
<IonRouterOutlet id="main">
<Route path="/" component= {Registro } exact={true}/>
</IonRouterOutlet>
</IonSplitPane>
</IonReactRouter>
</IonApp>
);
}
else{
return (
<IonApp>
<IonReactRouter>
<IonSplitPane contentId="main" when="(min-width: 4096px)">
<Menu />
<IonRouterOutlet id="main">
<Route path="/" component= {Home} exact={true}/>
</IonRouterOutlet>
</IonSplitPane>
</IonReactRouter>
</IonApp>
);
}
};
Thanks in advance.
1 post - 1 participant