Data binding in React

前端 未结 12 789
心在旅途
心在旅途 2021-01-30 19:49

What I want to do is when I type some text in an input field, it should appear in another place realtime.

Below is my input;



        
12条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-30 20:38

    class App extends React.Component {
      constructor() {
        super();
        this.state = {value : ''}
      }
      handleChange = (e) =>{ 
        this.setState({value: e.target.value});
      }
      render() {
        return (
        
    {this.state.value}
    ) } } ReactDOM.render(, document.getElementById('app'));
    
    
    

提交回复
热议问题