Use custom Navigate instead of react-router

This commit is contained in:
Kalle
2022-04-16 19:26:06 +03:00
parent 68ead9c9b9
commit a249b7bfa7
3 changed files with 13 additions and 2 deletions

View File

@@ -0,0 +1,11 @@
import { useNavigate } from "@remix-run/react";
import * as React from "react";
export function Navigate({ to }: { to: string }) {
const navigate = useNavigate();
React.useEffect(() => {
navigate(to);
}, [navigate, to]);
return null;
}

View File

@@ -24,8 +24,8 @@ import {
import manageStylesUrl from "~/styles/tournament-manage.css";
import { parseRequestFormData, requireUser, Unpacked, validate } from "~/utils";
import { useUser } from "~/hooks/common";
import { Navigate } from "react-router";
import { tournamentFrontPage } from "~/utils/urls";
import { Navigate } from "~/components/Navigate";
const manageActionSchema = z.object({
_action: z.enum(["CHECK_OUT", "CHECK_IN", "UNREGISTER"]),

View File

@@ -20,8 +20,8 @@ import { parseRequestFormData, requireUser } from "~/utils";
import { tournamentFrontPage, tournamentManageTeamPage } from "~/utils/urls";
import * as TournamentTeam from "~/models/TournamentTeam.server";
import { FindTournamentByNameForUrlI } from "~/services/tournament";
import { Navigate } from "react-router";
import { PleaseLogin } from "~/components/PleaseLogin";
import { Navigate } from "~/components/Navigate";
export const links: LinksFunction = () => {
return [{ rel: "stylesheet", href: styles }];