Как перейти на другую страницу с 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