Is there ever a situation where componentDidUpdate would NOT fire, even if the props updated in React?
相关问题
- How to toggle on Order in ReactJS
- Refreshing page gives Cannot GET /page_url in reac
- Adding a timeout to a render function in ReactJS
- React Native Inline style for multiple Text in sin
- Issue with React.PropTypes.func.isRequired
相关文章
- Why would we use useEffect without a dependency ar
- Is it possible to get ref of props.children?
- Stateless function components cannot be given refs
- React testing library: Test attribute / prop
- React/JestJS/Enzyme: How to test for ref function?
- Material-UI [v0.x] RaisedButton on hover styles
- Remove expo from react native
- ReactJS toLowerCase is not a function
this can also happen, if your component is in a list and the key of your component changes (ie. on every render) or the key is missing, or the key is duplicate, etc.
refer to docs for details: https://reactjs.org/docs/lists-and-keys.html
There are 3 conditions that can cause componentDidUpdate to not fire:
1) You wrote a custom shouldComponentUpdate that returned false.
2) The internal react methods determined that there was no change in the virtual DOM, so it chose not to re-render.
3) You extended something other than React.Component (such as PureComponent) which has a default shouldComponentUpdate method that returned false.
You can suppress a render with returning false in
shouldComponentUpdate()
. So yes, in that casecomponentDidUpdate()
won't fire.