FrontendDeveloper.in

React question detail

What is the difference between `setState()` and `replaceState()` methods?

When you use setState() the current and previous states are merged. replaceState() throws out the current state, and replaces it with only what you provide. Usually setState() is used unless you really need to remove all previous keys for some reason. You can also set state to false/null in setState() instead of using replaceState().

Back to all React questions
Get LinkedIn Premium at Rs 399