Want I am missing in the below code


#1


Problem in React Forms - 3rd ex; 

Problem statement is - Select Input.js.

Before Input's render function, write a new property named handleUserInput. Make handleUserInput's value a function.

Give this function one parameter, named e.

Inside of this function's body, call this.setState. Set the state's userInput property equal to e.target.value.

e.target.value will equal the text in the <input /> field. You are setting this.state.userInput equal to whatever text is currently in <input />.

Could you anybody help me what i am missing in that code. 
 

var React = require('react');
var ReactDOM = require('react-dom');

var Input = React.createClass({
  handleUserInput: function (){
    this.setState({
      userInput: e.target.value
    })
  };
  render: function () {
    return (
      <div>
        <input 
          type={this.state.userInput}
          onChange={this.handleUserInput} />
        <h1>I am an h1.</h1>
      </div>
    );
  }
});

ReactDOM.render(
	<Input />,
	document.getElementById('app')
);


#2
    <input 
      type="text" 
      onChange={this.handleUserInput} 
      value=""/>

This is correct answer。


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.