You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
memos/web/src/App.tsx

22 lines
592 B
TypeScript

import { useEffect, useState } from "react";
4 years ago
import { appRouterSwitch } from "./routers";
import { locationService } from "./services";
import { useAppSelector } from "./store";
4 years ago
function App() {
const pathname = useAppSelector((state) => state.location.pathname);
const [isLoading, setLoading] = useState(true);
4 years ago
useEffect(() => {
locationService.updateStateWithLocation();
window.onpopstate = () => {
locationService.updateStateWithLocation();
};
setLoading(false);
}, []);
return <>{isLoading ? null : appRouterSwitch(pathname)}</>;
4 years ago
}
export default App;