class Parent extends React.Component {
state = { c2: null }
comp2state = state => { this.setState({ c2: state }) }
return (
<>
<ComponentOne c2state={this.state.c2} />
<ComponentTwo onStateChange={this.comp2state} />
</>
)
}
class ComponentTwo extends React.Component {
state = { bla: '' }
onChange = e => {
this.setState(
{ bla: e.target.value },
() => this.props.onStateChange(this.state)
)
}
return (
<input value={this.state.bla} onChange={onChange} />
)
}