-
Notifications
You must be signed in to change notification settings - Fork 50.4k
Description
Disclamer: low priority enhancement request, simply a cryptic error message on bad React usage that could be enhanced
In our internal framework, we always keep the full state outside of React and always rerender from the top (a bit like Om but without any local state -> React is just a template engine)
In our code, we have mistakenly triggered a rendering during a rendering (during componentWillUpdate phase, which our internal framework should forbid anyway to avoid infinite rendering loops). And we mesure all renderings.
This somehow lead to the following code, that permits to easily reproduce this error:
http://jsfiddle.net/kb3gN/4956/
/** @jsx React.DOM */
var Hello = React.createClass({
componentWillUpdate: function() {
React.addons.Perf.start();
React.addons.Perf.stop();
React.addons.Perf.printWasted();
},
render: function() {
return <div>Hello {this.props.name}</div>;
}
});
var component = <Hello name="World" />;
React.addons.Perf.start();
React.renderComponent(component, document.body);
React.addons.Perf.stop();
React.addons.Perf.printWasted();
React.addons.Perf.start();
React.renderComponent(component, document.body);
React.addons.Perf.stop();
React.addons.Perf.printWasted();
So yes, this is probably a bad usage of React but the cryptic error message could be made more explicit of what we did wrong.