Skip to content

Problem with event.target.value for input with fixed value #2444

Closed
@menelaos

Description

@menelaos

Check the following example:

var Example = React.createClass({
  getInitialState: function() {
      return {value: 'Try to type or backspace!'};
  },
  handleChange: function(event) { 
    this.setState({value: event.target.value});
  },
  render: function() { 
    return ( 
      <div>
        <div>{this.state.value}</div>
        <input type="text" value="fixed" onChange={this.handleChange} />
      </div>
    );
  } 
});

The first div's content will either read "fixe" (on backspace) or "fixed{lastKeyPressed}".
Intuitively, it should always read "fixed".

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