![]() |
1
3
你的代码很复杂,所以我建议你试着重构它。 但无论如何,我建议使用“componentDidUpdate”
React文档(用于“componentDidUpdate”): https://reactjs.org/docs/react-component.html#componentdidupdate 反应文档(用于“不安全组件将接收道具”): https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops
|
![]() |
2
1
正如@Tzook Bar Noy所解释的,React团队强烈建议不要使用
我建议,因为您在代码中没有使用实例方法,所以使用新的
如果它适用于您的用例,请签入react docs。有趣的文章: https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html 你的代码可能是这样的:
|
![]() |
Ângelo Rigo · ReactJS映射:如何迭代[关闭] 6 月前 |
![]() |
vatsal chauhan · 即使在字体预加载时,文本加载也很慢 6 月前 |
![]() |
noblerare · Vite错误-未定义导出(SSR) 6 月前 |