In the event object event in react, target is viewed as null, in the console, but event.target can get the target element. why?

Code:

input:

Why does event.target get it correctly for the determination below null,

Mar.20,2021

this is because the events in React are not real DOM events, but rather composite events encapsulated on native DOM events.
Composite events are managed by the event pool, the composite event object may be reused, and all properties of the composite event are emptied. So when accessing the properties of a composite event in an asynchronous handler (such as setTimeout, etc.) or in the browser console, it may be empty.
the solution given in the answer above: event.persist (), simply removes the current composite event from the event pool, so you can continue to have a reference to the event and still have access to the event's properties.


event is only the current object
default react sets all its properties to null


function(e){
          e.persist()
          console.log(e);
        }
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4da99-44f58.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4da99-44f58.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?