reactjs 如何将useState setter作为param传递?它的类型是什么?

zy1mlcev  于 2022-11-29  发布在  React
关注(0)|答案(1)|浏览(112)

我有这样的使用状态:

const [imgIdUploded, setImageIdUploaded] = useState<string | undefined>(
    undefined
)

写什么类型?

export default function BuyTicketForm(props: {
    setImageIdUploaded?: ?????
fcg9iug3

fcg9iug31#

类型为Dispatch<SetStateAction<YOUR_TYPE>

import { Dispatch, SetStateAction } from "react";

export default function BuyTicketForm(props: {
    setImageIdUploaded?: Dispatch<SetStateAction<string | undefined>>

相关问题