From 1e4023ed7d2faa6359e4face10b4dd7237bcb484 Mon Sep 17 00:00:00 2001 From: Sophie Alpert Date: Wed, 1 Jan 2020 08:40:36 -0800 Subject: [PATCH] Add note about skipped updates with noop setState Fixes #2599. --- content/docs/hooks-reference.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/content/docs/hooks-reference.md b/content/docs/hooks-reference.md index 6d1c4785..fda18f90 100644 --- a/content/docs/hooks-reference.md +++ b/content/docs/hooks-reference.md @@ -69,6 +69,8 @@ function Counter({initialCount}) { The "+" and "-" buttons use the functional form, because the updated value is based on the previous value. But the "Reset" button uses the normal form, because it always sets the count back to the initial value. +If your update function returns the exact same value, the subsequent rerender will be skipped completely. + > Note > > Unlike the `setState` method found in class components, `useState` does not automatically merge update objects. You can replicate this behavior by combining the function updater form with object spread syntax: