Jak przejść do innej strony z Settimeout ReactJs
import { useState } from "react";
import { Redirect } from "react-router-dom";
function SplashScreen() {
const [redirectNow, setRedirectNow] = useState(false);
setTimeout(() => setRedirectNow(true), 2000);
return redirectNow ? (
<Redirect to="/game" />
) : (
<div className="SplashScreen">
<h1>Hello World</h1>
</div>
);
}
export default SplashScreen;
Ana Matei