I have an input component that gets url as input and resolve it (resolve=get somehow a preview for that url):
var resolver = require('resolver');
var UrlResolver = React.createClass({
statics: {
storeListeners: {
onResolverStore: [ ResolverStore ]
}
},
getInitialState: function() {
return { value: '', resolves: [] };
},
onResolverStore: function(data) {
var resolves = [].concat(this.state.resolves, data);
this.setState({ resolves: resolves });
},
handleChange: function(event) {
var value = event.target.value;
this.setState({ value: value });
this.executeAction(resolver, value);
},
render: function () {
return (
<input value={ this.state.value } onChange={ this.handleChange } />
{
this.state.resolves.map(function(data) {
return <ResolveView data={ data } />;
});
}
);
}
});
As you can see, UrlResolver waits for changes on ResolverStore. Such changes can be happen when there is a change on the input. My problem is when I have 10 UrlResolvers on my view. In this situation, any change on one input will change ResolverStore that will trigger 10 different events and so 10 different setStates that will cause 10 re-renders. All this whereas only one input should handle this change. This way 9 components will also add a resolve data that is not belong to them.
What is the solution for such need?