简单React
0 1

常见 在React中,组件的props改变时,更新组件的方法 有哪些?分别说明?

【概念释义】

Props 变化时组件更新路径:函数组件重新执行 render;类组件 shouldComponentUpdate → render → 生命周期。强制更新:forceUpdate(类)或改 key remount。优化:React.memo 浅比较 props;useMemo 稳定子 props。Derived:getDerivedStateFromProps 从 props 同步 state(慎用)。

【基础使用】

jsx
const Child = React.memo(function Child({ value }) {

登录查看完整 1138

回答讨论

暂无讨论,登录后可抢先发言

本题库更多题目(50)