Skip to content

'Bind' will result in errors in onClick handler #6306

@superddr

Description

@superddr

If you create any react component, and add this attribute to it:
onClick={this.setState.bind(this, {smKey:smValue} )}

then you click it, it will report an error:

Uncaught Invariant Violation: enqueueCallback(...): You called setProps, replaceProps, setState, replaceState, or forceUpdate with a callback that isn't callable.

but actually it's working, the state will be correctly updated, nothing wrong, just the annoying error.

I think this is a bug, but I can not image how could it be, when this can work:
onClick={()=>this.setState({smKey,smValue})}

to me they are exactly the same things.

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