Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

React Controlled Components

class NameForm extends React.Component {
  constructor(props) {
    super(props);
    this.state = {value: ''};
    this.handleChange = this.handleChange.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);
  }

  handleChange(event) {    this.setState({value: event.target.value});  }
  handleSubmit(event) {
    alert('A name was submitted: ' + this.state.value);
    event.preventDefault();
  }

  render() {
    return (
      <form onSubmit={this.handleSubmit}>        <label>
          Name:
          <input type="text" value={this.state.value} onChange={this.handleChange} />        </label>
        <input type="submit" value="Submit" />
      </form>
    );
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: react native bottom sheet 
Javascript :: scroll top javascript 
Javascript :: react router params and render 
Javascript :: inline styling to change background color 
Javascript :: add two empty arrays javascript 
Javascript :: map and filter js 
Javascript :: JavaScript Destructuring - From ES6 
Javascript :: get props from methods in vue 
Javascript :: esql convert blob to json 
Javascript :: Least common multiple from array 
Javascript :: javascript log where function was called 
Javascript :: why to use arrow functions over normal function 
Javascript :: javascript random number 
Javascript :: method example js 
Javascript :: javascript symbols 
Javascript :: Image resize using html and javascript 
Javascript :: discord js check every x minutes 
Javascript :: disable js on chrome 
Javascript :: This function is used to store items in local storage 
Javascript :: Why do you need JSON 
Javascript :: js index to index 
Javascript :: javascript github 
Javascript :: nested function 
Javascript :: How to pass methods in vue js 
Javascript :: Map put() method 
Javascript :: javascript if function multiple conditions 
Javascript :: javascript image preview before upload 
Javascript :: require vs import 
Javascript :: get all recod from db nodejs mongodb 
Javascript :: reducer react 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =