React: Difference between currentTarget and target of SyntheticEvent

Created on 25 Dec 2015  ·  4Comments  ·  Source: facebook/react

There is 2 properties in SyntheticEvent, currentTarget and target.
It is identical usage? or what is the difference between them?

Unconfirmed Question

Most helpful comment

It mimics the DOM Event object API which also has currentTarget and target.

From currentTarget documentation:

It always refers to the element the event handler has been attached to as opposed to event.target which identifies the element on which the event occurred.

All 4 comments

It mimics the DOM Event object API which also has currentTarget and target.

From currentTarget documentation:

It always refers to the element the event handler has been attached to as opposed to event.target which identifies the element on which the event occurred.

I have problem with them: currentTarget has null, but in target I have currentTarget element

@max-mykhailenko Can you provide a jsfiddle that demonstrates the issue? It appears to work in my fiddle: https://jsfiddle.net/gpm18sqd/

2850 seems to explain the reason for this bug.

Was this page helpful?
0 / 5 - 0 ratings