avatarJasper Dunn

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

207

Abstract

tle">setSearches</span><span class="hljs-params">(searches => [...searches, newSearch])</span></span></pre></div><p id="5f53">This is especially important inside functions that execute very often and have

Options

multiple uses of the same setter function.</p><p id="e7b3">The value of searches accessed from the initial hook may be different than is expected, and this could unwanted side effects.</p></article></body>

In most situations it’s best to use the state param inside the setter function itself.

e.g.

setSearches(searches => [...searches, newSearch])

This is especially important inside functions that execute very often and have multiple uses of the same setter function.

The value of `searches` accessed from the initial hook may be different than is expected, and this could unwanted side effects.

Recommended from ReadMedium