score:8

Accepted answer

you need to call a parent function that updates a state in the parent and then pass it as a prop to the first child

parent

..
changeselected = (val) => {
     this.setstate({selected: val})
}

render() {
  return (
     <div>
     <firstchild selected={this.state.selected}/>
     <secondchild changeselected = {(val)=> {this.changeselected(val)}}/>
     </div>
  )
}

firstchild:

render() {
    console.log(this.props.selected);
}

secondchild:

handleclick = (val) => {
    this.props.changeselected(val);
}

Related Query

More Query from same tag