Skip to content

React Perf: "cannot set property totalTime of undefined" #2095

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
slorber opened this issue Aug 27, 2014 · 1 comment
Closed

React Perf: "cannot set property totalTime of undefined" #2095

slorber opened this issue Aug 27, 2014 · 1 comment

Comments

@slorber
Copy link
Contributor

slorber commented Aug 27, 2014

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.

@gaearon gaearon mentioned this issue Mar 18, 2016
30 tasks
@gaearon
Copy link
Collaborator

gaearon commented Oct 27, 2016

I think this is supported in new ReactPerf.

@gaearon gaearon closed this as completed Oct 27, 2016
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants