"use client"; import { addToken } from "@/lib/actions/token"; import { Token } from "@/lib/types"; import { useEffect, useRef } from "react"; import { useFormState } from "react-dom"; export default function TokenButton({ className, token, }: { className?: string | undefined; token: Token; }) { const ref = useRef(null); const [returnType, dispatch] = useFormState(addToken, token); // TODO 有没有更合适的方式? if (returnType) { ref.current?.close(); } return ( <>

Token 设定

); }