How to replace page use jsx

I want to float the main page when the token exists. but it isn’t movement my code.. plz help me TT

const App = () => {
    const [token, setToken] = useState(null);

    useEffect(()=> {
        const hash = getTokenFromResponse();
        window.location.hash = "";
        const token = hash.access_token;

        console.log('token', token);

        const userManager = {
          token : token,
        };

        console.log(userManager);
        
    }, []);
    return(
        <div className="login">
          {!token && <Login/>}
          {token && <Main/>}
        </div>
    )
}

Answer

You forgot to update the state

useEffect(()=> {

   // ...

   setToken(token)
}, []);