Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference between currentTarget and target of SyntheticEvent #5733

Closed
markliu2013 opened this issue Dec 25, 2015 · 4 comments
Closed

Difference between currentTarget and target of SyntheticEvent #5733

markliu2013 opened this issue Dec 25, 2015 · 4 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Question

Comments

@markliu2013
Copy link

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

@gaearon
Copy link
Collaborator

gaearon commented Dec 25, 2015

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.

@max-mykhailenko
Copy link

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

@jimfb
Copy link
Contributor

jimfb commented Jan 12, 2016

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

@jimfb jimfb added Type: Question Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug labels Jan 12, 2016
@jimfb jimfb closed this as completed Feb 10, 2016
@kun-zhou
Copy link

#2850 seems to explain the reason for this bug.

SamChou19815 added a commit to cornell-dti/office-hours that referenced this issue Apr 26, 2020
### Summary

Use currentTarget since it's more reliable, and it solves the problem.

### Test Plan

Type a letter. It no longer crashes.

### Notes

facebook/react#5733
SamChou19815 added a commit to cornell-dti/office-hours that referenced this issue Apr 26, 2020
### Summary

Use currentTarget since it's more reliable, and it solves the problem.

### Test Plan

Type a letter. It no longer crashes.

### Notes

facebook/react#5733
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Question
Projects
None yet
Development

No branches or pull requests

5 participants