The concept of passing data from parent to child and vice versa is explained.
import React, { Component } from "react";_x000D_
import ReactDOM from "react-dom";_x000D_
_x000D_
// taken refrence from https://gist.github.com/sebkouba/a5ac75153ef8d8827b98_x000D_
_x000D_
//example to show how to send value between parent and child_x000D_
_x000D_
// props is the data which is passed to the child component from the parent component_x000D_
_x000D_
class Parent extends Component {_x000D_
constructor(props) {_x000D_
super(props);_x000D_
_x000D_
this.state = {_x000D_
fieldVal: ""_x000D_
};_x000D_
}_x000D_
_x000D_
onUpdateParent = val => {_x000D_
this.setState({_x000D_
fieldVal: val_x000D_
});_x000D_
};_x000D_
_x000D_
render() {_x000D_
return (_x000D_
// To achieve the child-parent communication, we can send a function_x000D_
// as a Prop to the child component. This function should do whatever_x000D_
// it needs to in the component e.g change the state of some property._x000D_
//we are passing the function onUpdateParent to the child_x000D_
<div>_x000D_
<h2>Parent</h2>_x000D_
Value in Parent Component State: {this.state.fieldVal}_x000D_
<br />_x000D_
<Child onUpdate={this.onUpdateParent} />_x000D_
<br />_x000D_
<OtherChild passedVal={this.state.fieldVal} />_x000D_
</div>_x000D_
);_x000D_
}_x000D_
}_x000D_
_x000D_
class Child extends Component {_x000D_
constructor(props) {_x000D_
super(props);_x000D_
_x000D_
this.state = {_x000D_
fieldValChild: ""_x000D_
};_x000D_
}_x000D_
_x000D_
updateValues = e => {_x000D_
console.log(e.target.value);_x000D_
this.props.onUpdate(e.target.value);_x000D_
// onUpdateParent would be passed here and would result_x000D_
// into onUpdateParent(e.target.value) as it will replace this.props.onUpdate_x000D_
//with itself._x000D_
this.setState({ fieldValChild: e.target.value });_x000D_
};_x000D_
_x000D_
render() {_x000D_
return (_x000D_
<div>_x000D_
<h4>Child</h4>_x000D_
<input_x000D_
type="text"_x000D_
placeholder="type here"_x000D_
onChange={this.updateValues}_x000D_
value={this.state.fieldVal}_x000D_
/>_x000D_
</div>_x000D_
);_x000D_
}_x000D_
}_x000D_
_x000D_
class OtherChild extends Component {_x000D_
render() {_x000D_
return (_x000D_
<div>_x000D_
<h4>OtherChild</h4>_x000D_
Value in OtherChild Props: {this.props.passedVal}_x000D_
<h5>_x000D_
the child can directly get the passed value from parent by this.props{" "}_x000D_
</h5>_x000D_
</div>_x000D_
);_x000D_
}_x000D_
}_x000D_
_x000D_
ReactDOM.render(<Parent />, document.getElementById("root"));
_x000D_