Skip to content

onChange not firing on controlled input element when value is updated #8971

@pudgereyem

Description

@pudgereyem

I've found what to me appears as a bug.

Bug

When a controlled input element changes by updating it's value, onChange isn't called.

Reproduction

I made a codepen that illustrates the problem; http://codepen.io/pudgereyem/live/bgmvOq

Expected behaviour

I expect that onChange gets called, since the <input/> did change, and the world of React is by nature very much "controlled".

This is written in the docs and also mentioned in various threads such as #8550 (comment) and #8696 (comment).

My problem

The fact that the inputs onChange function not gets called is a problem to me, because I need to do logic (such as validation) when the inputs have changed.

Comments

  • I tried using onInput also, but it doesn't get called either

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions