Event target is null inside functional setState

Posted by Jennifer | Updated on

Event target is null inside functional setState. That is because of React doing event pooling – all the event’s fields get nullified after the callback is done, so you observe them as nulls in the asynchronous setState callback.

Please copy your event data to a variable or call event.persist() to disable this behaviour.

If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers