How do I access one component\'s state in another component? Below is my code and I\'m trying to access the state of component a in component b.
in the child component create function that sets the state:
changeTheState(){
this.setState({something:"some value"})
}
and in parent component give the child a ref as following:
this._child = component}/>
then in parent make a function to access the changeTheState()
parentFunction(){
this._child.changeTheState();
} and just use the parentFunction.