react 使用 useState useRef 添加TS使用方式

useState

type RecordItem = {
    title: string;
    total: number;
    id: number;
    color: string;
}

const [list, setList] = React.useState<RecordItem[]>(recordList);

useRef

const ref = useRef<HTMLElement | null>(null);

 

posted @ 2022-07-18 17:14  玖捌  阅读(874)  评论(0)    收藏  举报