react hooks API摘要整理
Hooks API
1. useState
const [state, setState] = useState(initialState);
函数式更新state
setState(preCount => preCount + 1);
setStete(preCount => preCount - 1);
如果pre 和 curent是完全相同的,则随后的重渲染会被跳过。
合并新老对象
const [state, setState] = useState({});
setState(p
原创
2021-11-22 21:51:56 ·
528 阅读 ·
0 评论