4-7 章节 `add` 方法应该是有些问题的
来源:4-7 作业解答 - ⽤ Hook + TS + TS泛型实现useArray

dyq666
2021-12-07
If the new state is computed using the previous state, you can pass a function to setState.
add: (item: T) => setValue([...value, item])
add: (item: T) => setValue((prevValue) => [...prevValue, item])
写回答
1回答
-
Modraut
2021-12-21
这两种写法没什么大区别吧,用哪个都行
00
相似问题
1-4的代码呢???
回答 1
useArray使用[]返回该如何写?
回答 1