将整个前端部分页面处理id的方式,由使用 params.id 的方式全部迁移到 React.use(params) 这种方式
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import type React from "react"
|
||||
import { useState, useEffect, use } from "react"
|
||||
import * as React from "react"
|
||||
import { useState, useEffect } from "react"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Input } from "@/components/ui/input"
|
||||
@@ -12,6 +12,12 @@ import { ArrowLeft, Plus, Trash } from "lucide-react"
|
||||
import Link from "next/link"
|
||||
import { toast, Toaster } from "sonner"
|
||||
|
||||
// 为React.use添加类型声明
|
||||
declare module 'react' {
|
||||
function use<T>(promise: Promise<T>): T;
|
||||
function use<T>(value: T): T;
|
||||
}
|
||||
|
||||
interface Device {
|
||||
id: number
|
||||
memo: string
|
||||
@@ -40,7 +46,7 @@ export default function EditProjectPage({ params }: { params: { id: string } })
|
||||
const [project, setProject] = useState<Project | null>(null)
|
||||
const [password, setPassword] = useState("")
|
||||
const [confirmPassword, setConfirmPassword] = useState("")
|
||||
const id = params.id
|
||||
const { id } = React.use(params)
|
||||
|
||||
useEffect(() => {
|
||||
const fetchProject = async () => {
|
||||
|
||||
Reference in New Issue
Block a user