mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-07 19:55:46 -05:00
useTransition -> useNavigation (deprecation)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { type FetcherWithComponents, useTransition } from "@remix-run/react";
|
||||
import { type FetcherWithComponents, useNavigation } from "@remix-run/react";
|
||||
import { Button, type ButtonProps } from "./Button";
|
||||
|
||||
interface SubmitButtonProps extends ButtonProps {
|
||||
@@ -14,9 +14,9 @@ export function SubmitButton({
|
||||
testId,
|
||||
...rest
|
||||
}: SubmitButtonProps) {
|
||||
const transition = useTransition();
|
||||
const navigation = useNavigation();
|
||||
|
||||
const isSubmitting = state ? state !== "idle" : transition.state !== "idle";
|
||||
const isSubmitting = state ? state !== "idle" : navigation.state !== "idle";
|
||||
|
||||
return (
|
||||
<Button
|
||||
|
||||
@@ -4,7 +4,7 @@ import type {
|
||||
MetaFunction,
|
||||
} from "@remix-run/node";
|
||||
import { json, redirect } from "@remix-run/node";
|
||||
import { useFetcher, useLoaderData, useTransition } from "@remix-run/react";
|
||||
import { useFetcher, useLoaderData, useNavigation } from "@remix-run/react";
|
||||
import * as React from "react";
|
||||
import { z } from "zod";
|
||||
import { Button } from "~/components/Button";
|
||||
@@ -185,13 +185,13 @@ function Impersonate() {
|
||||
function MigrateUser() {
|
||||
const [oldUserId, setOldUserId] = React.useState<number>();
|
||||
const [newUserId, setNewUserId] = React.useState<number>();
|
||||
const transition = useTransition();
|
||||
const navigation = useNavigation();
|
||||
const fetcher = useFetcher();
|
||||
|
||||
const submitButtonText =
|
||||
transition.state === "submitting"
|
||||
navigation.state === "submitting"
|
||||
? "Migrating..."
|
||||
: transition.state === "loading"
|
||||
: navigation.state === "loading"
|
||||
? "Migrated!"
|
||||
: "Migrate";
|
||||
|
||||
@@ -221,7 +221,7 @@ function MigrateUser() {
|
||||
<div className="stack horizontal md">
|
||||
<SubmitButton
|
||||
type="submit"
|
||||
disabled={!oldUserId || !newUserId || transition.state !== "idle"}
|
||||
disabled={!oldUserId || !newUserId || navigation.state !== "idle"}
|
||||
_action="MIGRATE"
|
||||
state={fetcher.state}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user