react return value from component

Solutions on MaxInterview for react return value from component by the best coders in the world

showing results for - "react return value from component"
Asia
17 Aug 2018
1class Parent extends Component {
2  constructor() {
3    this.state = {
4      value: ''
5    };
6  }
7
8  //...
9
10  handleChangeValue = e => this.setState({value: e.target.value});
11
12  //...
13
14  render() {
15    return (
16      <Child
17        value={this.state.value}
18        onChangeValue={this.handleChangeValue}
19      />
20    );
21  }
22}
23
24class Child extends Component {
25  //...
26
27  render() {
28    return (
29      <input
30        type="text"
31        value={this.props.value}
32        onChange={this.props.onChangeValue}
33      />
34    );
35  }
36}
37