adspace
What is the difference between setstate() and forceupdate()?
Answer Posted / Kishalaya Kumar
`setState()` is a method in React components that allows you to update the component's state. When `setState()` is called, the component is re-rendered with the new state.nn`forceUpdate()`, on the other hand, forces the component to re-render without updating the state. It should be used sparingly and only when necessary, as it can lead to unexpected behavior.nnYou should generally use `setState()` to update your component's state and trigger a re-render, unless you have a specific reason to use `forceUpdate()`.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers