Reputation: 331
Could you please help me with this?
What I want to do is check if the user is registered. If it is registered it should show the home url and if it is not registered it should show the registration url.
For that I see and check the saved data (isRegistered), if it equals to null is not registered and should show the /register url. But its not working.
In the next line I have an error
const [isReg, setIsReg] = useState(false);
And it gives me this error:
Expression expected.ts(1109)
const App: React.FC = () => (
const [isReg, setIsReg] = useState<boolean>(false);
if(getItem("isRegistered")==null){
console.log(getItem("isRegistered"));
useState(true);
}
else{
useState(false);
}
<IonApp>
<IonReactRouter>
<IonSplitPane contentId="main" when="(min-width: 4096px)">
<Menu />
<IonRouterOutlet id="main">
<Route path="/" render={() => isReg ? {Home} : {Registro}} />
<Route path="/Favorites" component={Favoritos} exact={true}></Route>
</IonRouterOutlet>
</IonSplitPane>
</IonReactRouter>
</IonApp>
);
Upvotes: 3
Views: 4835
Reputation: 706
it should be
useEffect(() => {
if(getItem("isRegistered")==null){
console.log(getItem("isRegistered"));
setIsReg(true);
}
else{
setIsReg(false);
}
}, [])
Upvotes: 1