index.html
, то и конфигурацию поправьте.export const useVerifyAuth = () => {
const { setIsAuth, setUser, setIsLoading } = useUserStore();
const pathname = usePathname();
const { data, error, isLoading, isFetching, refetch } = useQuery({
queryKey: ["verify-auth"],
queryFn: () => authService.getNewTokens()
});
useLayoutEffect(() => {
if (error !== null) {
setIsAuth(false);
setUser(null);
}
if (data !== null) {
setIsAuth(true);
setUser(data.data.user);
}
}, [data, error])
useEffect(() => {
// Тут бы проверить, что прошлый pathname не равен текущему
refetch();
}, [pathname, refetch]);
useEffect(() => {
setIsLoading(isLoading || isFetching)
}, [isLoading, isFetching]);
};
const routes: RouteObject[] = [
{
path: "*",
element: <Outlet />,
children: [
{
id: "page-a",
path: "page-a",
element: <PageA />,
},
{
id: "page-b",
path: "page-b",
element: <PageB />,
},
],
},
];
export const Router: FC = () => {
const router = createBrowserRouter(routes);
return <RouterProvider router={router} />;
};
export const SuperWrapper: FC = () => {
return (
<ThemeProvider theme={theme}>
<Notifications />
<Outlet />
</ThemeProvider>
);
};
someComponent()
, то Вас ждёт удивительный мир потери состояний и прочего. base
- пример.homepage
.<div className="reference-container">
<div className="reference-container-panel">
{isToolsVisible && <div className="tools"></div>}
{isSeracpPanleVisible && <div className="searchPanel"</div>}
</div>
<div className="mainContent"></div>
</div>
.reference-container {
height: 100%;
display: grid;
grid-template-rows: max-content 1fr;
}
.reference-container-panel {
display: grid;
grid-auto-rows: max-content;
}
.reference-container-panel:empty {
display: none;
}
.tools {
height: 100px;
}
.searchPanel {
height: 50px;
}
import * as React from "react";
import { DemoContainer } from "@mui/x-date-pickers/internals/demo";
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
import { DatePicker } from "@mui/x-date-pickers/DatePicker";
import { StaticDatePicker } from "@mui/x-date-pickers/StaticDatePicker";
import dayjs, { Dayjs } from "dayjs";
export default function BasicDatePicker() {
const [date, setDate] = React.useState<Dayjs | null>(dayjs());
const onDateChange = React.useCallback((value: Dayjs) => {
setDate(value);
}, []);
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DemoContainer components={["DatePicker", "StaticDatePicker"]}>
<DatePicker<Dayjs>
value={date}
views={["month"]}
onChange={onDateChange}
/>
<StaticDatePicker<Dayjs>
value={date}
orientation="landscape"
onChange={onDateChange}
/>
</DemoContainer>
</LocalizationProvider>
);
}
classes.bar
для элементов. А чтобы не городить такое `${classes.loader} js--loader`
можно использовать clsx или classnames.