简单React
0 1

React 的 componentWillReceiveProps 的触发条件是什么?

【概念释义】

componentWillReceiveProps(nextProps)(现 UNSAFE_componentWillReceiveProps)在父 re-render 导致 props 变化非 initial mount时调用,早于 render。用于 props 变同步 state(已不推荐,用 getDerivedStateFromProps 或 fully controlled)。React 17+ StrictMode 可能双调用;即将废弃,迁移 useEffect([props]) 或 key remount。

【基础使用】

jsx

登录查看完整 1171

回答讨论

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

本题库更多题目(50)