reactjs - 当且仅当调用render时才调用componentDidUpdate?
问题描述
React 组件有一个render
方法,也可以有一个componentDidUpdate
方法。我的问题是:每次componentDidUpdate
渲染后都会被调用,是否有任何时候被调用但不是?componentDidUpdate
render
解决方案
componentDidUpdate
总是在 之后调用render
。因此,如果您阻止渲染,shouldComponentUpdate
例如,didUpdate
将永远不会被调用
是否有任何时候 componentDidUpdate 被调用但 render 不是?
不,componentDidUpdate
取决于render
被调用。但是相反的情况可能会发生,componentDidUpdate
在第一次渲染后不会被调用
推荐阅读
- c - 如何检查单词b(C lang)中单词a中的所有字符?
- python - 如何使用opencv的cv2.putTexttext显示文本2秒?
- featherlight.js - 使用 FeatherLight 打开后无法更改/获取输入值?
- python - Django Channels - 当 Group.send() 在 consumer.py 的循环中调用时,客户端只收到一条消息
- r - 地理编码的波斯参数在波斯系统语言环境中不起作用
- apache - 如何猜测模块名称
- php - CodeIgniter 验证未显示在表单上
- python - If Then Else 语句
- angular - 在Angular 5中保存登录用户对象的最佳位置是什么
- cmake - CMake 自定义目标不构建