You are doing a state change while rendering your component. By doing a state change you are triggering a new rendering, therefore you are creating a rendering loop.
You have to use the useEffect
hook in order to set your local state to your token value at first load. Here is the documentation:
https://reactjs.org/docs/hooks-effect.html
In your case you'll have to replace:
if (sessionStorage.getItem("token")) {
setStatus(true);
}
by:
useEffect(() => {
if (sessionStorage.getItem("token")) {
setStatus(true);
}
}, [])
You can leave the dependency array as empty if you want to trigger it only at first rendering of the component, or give it dependencies that if they changes will trigger the useEffect
again.