DEV Community

Cover image for React synthetic events

React synthetic events

nagwan sami on July 28, 2020

I would like a fresh start πŸ˜‡ React A JavaScript library used to build vivid shiny user interfacesπŸ₯°. Event The different ways the user uses ...
Collapse
 
ahmdtalat profile image
Ahmd Talat

Hey, This is such an amazing explanation for the Synthetic Events, Thank you :)

Collapse
 
seemcat profile image
Maricris Bonzo

This was the best explanation to React's SyntheticEvent that I could find! Thank you :-)

Collapse
 
nagwan profile image
nagwan sami

oh, thanks Maricris it means a lot to me 😍

Collapse
 
hamidh2 profile image
Hamid Hassani • Edited

You said the properties of the event object will reset but you didn't say anything when this will happen?

I didn't understand this statement: 'our handelArrowBtn() is called asynchronously
after the event object has been nullified '
I didn't get the point of how a simple and synchronous method should be called asynchronously here?

Collapse
 
nagwan profile image
nagwan sami

Hi Hamid, sorry for the late reply,
this happens once the event handler is invoked.
and for the asynchronous part, it was related to another example removed to keep the article light, thanks for the note

Collapse
 
striker2909 profile image
StrikEr2909

Event will nullified when you try to access it asynchronously. in above example, it should be wrapped in setTimeOut or promise.

Collapse
 
saikrishnabanda5 profile image
saikrishnabanda5

good one

Collapse
 
shalinabhargava profile image
Shalina Bhargava

This was so easy!! I came on this article after 2 articles and react official documentation, thank you!!

Collapse
 
junnuravikumar profile image
Junnu

Thank you.

Collapse
 
loaideveloper profile image
Loai-developer

In the first solution to the problem, event should be null once I invoked the handler, should't it?

Collapse
 
nagwan profile image
nagwan sami

Do u mean that the handler will not be executed till the event get nullifed?!

Collapse
 
a_m_h_gad profile image
Jad

I liked your way of writing πŸ’œ ..
Thanks for sharing

Collapse
 
nagwan profile image
nagwan sami

Thaaaank you😍,
Hope it helps

Collapse
 
kemoshousha309 profile image
Kareem Shousha

Great article πŸ‘
That's was very helpful for me

Collapse
 
ayahosnym profile image
Aya Hosny

Wow, previously I had a problem about this concept but now I understand it
thanks a million ....... God bless you

Collapse
 
nagwan profile image
nagwan sami

thanks, Aya, really happy it helps 😍

Collapse
 
trex777 profile image
Manish Kumar Sahu

Thanks for this great explanation !

Collapse
 
nagwan profile image
nagwan sami

Hope it helps πŸ₯°