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.






