export const useArray = <T>(initialArray: T[]) => {标签:jira,index,setValue,const,16,value,useArray,copy,initialArray From: https://blog.51cto.com/u_15460007/6052220
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);
},
};
};