首页 > 其他分享 >学习笔记jira项目16-实现useArray

学习笔记jira项目16-实现useArray

时间:2023-02-12 22:04:38浏览次数:42  
标签:jira index setValue const 16 value useArray copy initialArray


export const useArray = <T>(initialArray: T[]) => {
const [value, setValue] = useState(initialArray);
return {
value,
setValue,
add: (item: T) => setValue([...value, item]),
clear: () => setValue([]),
removeIndex: (index: number) => {
const copy = [...value];
copy.splice(index, 1);
setValue(copy);
},
};
};

标签:jira,index,setValue,const,16,value,useArray,copy,initialArray
From: https://blog.51cto.com/u_15460007/6052220

相关文章