-
Notifications
You must be signed in to change notification settings - Fork 46.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Perf.print*() method not working in 15.1.0: Cannot read property 'forEach' of undefined #6871
Comments
This probably happens because you’re running a production build of React, but ReactPerf only works in the development build. We need to make it clear by emitting a warning instead of crashing. |
Ah. Yes, I am indeed running Perf in production mode as I wanted to avoid PropType validation getting in the way of profiling. |
We’ll allow this in the future, but it isn’t possible at the moment. You can track #6627. |
If someone wants to take this, here’s what I’d do:
|
@gaearon Hi, I will try to fix this! |
Dang, just beat me to it |
@sashashakun Thanks! I put myself as assignee so I don’t forget to come back to it, but please work on it and feel free to ask any questions! |
@gaearon Great! Issue looks not difficult, but I want to do my best, so already started to work and because I don't have deep knowledge about React internals, have some questions: About this point:
if (!__DEV__) {
warning('some warning message here');
return false;
} at the beginning of each method it will be to much copy-paste, no? May be it will be better to make a separate helper, like a |
Sure, sounds good.
I think
Worth adding it to log the warning, but the return value should be an empty array anyway. Finally: I think we should make sure we don’t warn more than once. If somebody has |
Start my work in branch react-perf-warnings-changes:
Also, about steps before open PR:
Looking forward for your feedback. |
I suggest let’s open a PR now so I don’t forget to look into it? |
Note that warning() is a noop in prod builds. |
Haha, oops, I didn’t realize that 😞 . |
Let's just do a console.error. |
Ok, will fix this |
) Fixes facebook#6871 (cherry picked from commit 2a46103)
After upgrading to 15.1.0 I'm having trouble using the React Perf tools. I've done the following:
Added to one of my files:
I then launch my app in Chrome. Open the Dev Tools and run this in the console:
And I get:
The failure is on this line:
flushHistory.forEach(function (flush) {
.The same behaviour occurs for all other
print*
method such asprintInclusive()
andprintExclusive()
.The same behaviour occurs if I put the commands into my code (ie. NOT running in the Chrome Console).
The text was updated successfully, but these errors were encountered: