Search
Star
Feedback
Setup for Free
© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
Cleaning up setter function that is a function - Theo's Typesafe Cult
TTC
Theo's Typesafe Cult
•
3y ago
•
5 replies
Kyle | Duck
Cleaning up setter function that is a function
So I need to set my state to this
:
() => {}
() => {}
. However
, if you supply
() => {}
() => {}
to react in a setter
, like so
:
setState(() => {})
setState(() => {})
it will instead return an empty object
, since React uses that syntax to use the previous state
.
Is there a better way to do this than this
:
setState(() => () => {})
setState(() => () => {})
?
Theo's Typesafe Cult
Join
26,131
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Recent Announcements
Similar Threads
Was this page helpful?
Yes
No
Similar Threads
functional components vs functions that return jsx
TTC
Theo's Typesafe Cult / questions
4y ago
Send setter to `props.children`
TTC
Theo's Typesafe Cult / questions
3y ago
setInterval timer with state setter
TTC
Theo's Typesafe Cult / questions
4y ago
how to upload files with a handle function that is linked to a form
TTC
Theo's Typesafe Cult / questions
3y ago