Listen state changes in React.js

Let’s see how to  listen to state changes of functions like the given below example:

componentDidMount: function() {

 this.getSearchResults();

}

setState can be used to make changes to state in the component hierarchy.

If you want to listen to the state change from another component there are two ways to do that.

1. Pass handlers through props from a common parent and let it update the parent's state by using the hierarchy below the parent.

2. Look at the flux pattern to avoid an outburst of handlers cascading down the hierarchy. Flux pattern will move your state into data stores and allows components to watch them for any changes.