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(() => {}) 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(() => () => {})?
2 Replies
Kyle
Kyle2y ago
My title is pretty garbage, so I apologize lol
barry
barry2y ago
no is the best way lol you can make it more obvious though
const [example, setExample] = useState(() => {
return () => {};
});
const [example, setExample] = useState(() => {
return () => {};
});
Want results from more Discord servers?
Add your server