Skip to content

Undocumented alteration of onClick arguments #8354

@wikiwong

Description

@wikiwong

After upgrading from 15.3.2 to React/ReactDOM 15.4.0 , I noticed that the onClick synthetic event (and possibly others) is receiving arguments differently.

In 15.3.2, the onClick event (without any custom arguments being passed) receives 3 arguments

0 - Proxy
1 - undefined
2 - Event
(observed in the console of this jsfiddle: https://jsfiddle.net/u7b6zhfm/1/)

In 15.4.0, the onClick arguments look like:
0 - Proxy
1 - Event
(Again viewable in the console here: https://jsfiddle.net/ujuzLhse/)

This ended up causing problems in my application because in 15.3.2, I was passing an additional argument to a click handler, and expecting it to be received as the second argument. Once I upgraded to 15.4.0, the argument was being received as the third (after Proxy and Event).

I'm not so sure this is to be considered an "issue" with React, but I didn't see anything in the release notes in the way of event handling, so thought I would raise it just in case.

The way I ended up adjusting for this is by using the spread/rest operator when passing/receiving arguments in the event handler function, which may be the approach I should have taken to begin with

PS: Thank you for all the hard work you guys put into this, super excited for fiber! Rock on 🎸

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions