79102678

Date: 2024-10-18 15:20:42
Score: 2
Natty:
Report link

Yes,the reason is you have written the errormessage in dependency of useEffect so when you first time dispatch it, the errorMessage value is changed from null to some string so the code inside useEffect works. But now when you click it again, the errorMessage is not getting changed since it is already set to the message you have provided. So in order to make it work either you can include some random number on each dispatch or you have to apply some reset mechanism for that.

Reasons:
  • No code block (0.5):
  • Single line (0.5):
  • Low reputation (1):
Posted by: Anshul Kahar