In React, there is function to update the state in the class component using setState
. It has a callback function also which gets executed once the state is updated.
I want to do something similar with hooks. My requirement is: once the first state is updated then I want to update other states in a click handler in a functional component. How can we do this?
setFilterBy("read or unread");
setEmailList(list);
I have seen the following solution but this won't work for me as they are doing something in useEffect
and here I want to do it in a click handler: How to use `setState` callback on react hooks