Important note about `set` functions missing from new `useState` docs
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 11.8k
- Forks
- 7.9k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 11
Description
I was attending a class about useCallback in conjunction with useState in a custom hook, and the solution to my exercise used an empty dependency array in useCallback, even though it used a setValue from a state:
const [value, setValue] = React.useState(initialValue);
const toggleValue = React.useCallback(
() => setValue((currentValue) => !currentValue),
[] # I put [setValue] here
);
return [value, toggleValue];
I wasn't sure if this was ok, but didn't find any info about this in the new docs of useState. I asked around and found that the old docs do contain the specific information I was looking for:

I'd like to suggest to add this note or something similar in the new docs as well. It might have been omitted for a good reason, but it does feel like important information to me.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the new useState documentation, specifically the setstate section linked in the issue, and compare it with the corresponding legacy Hooks reference. Add the missing note or equivalent explanation about set functions and useCallback dependencies, then verify that the guidance is clear in the rendered documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100