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
Detect WDYR running too late #247
Comments
can you please try using a regular require rather than an import for the wdyr file? |
@vzaidman It works when I do it that way. Good point. A note of value for the README in some fashion... I remember moving away from Alternatively, is there any way |
It's a common problem indeed. I Guess we can add something that checks whether WDYR got initialized early enough. The problem is that I can't think of a way to check this. I'll leave it as a wish. |
I have an app that uses a lot of mainstream React libraries including
react-router
andreact-redux
. It's big so we also leverageReact.lazy
andReact.Suspense
.I recently noticed dev errors from React around hook render ordering. You know the one, where React yells at you if you have a hook running conditionally. Well in my case, I was getting the errors, but I was confident that I wasn't running hooks conditionally.
After a lot of investigating, I found the issue to be a simple combination of
why-did-you-render
andReact.lazy
.I don't propose to explain the reason for this issue, but I have come up with a simple-as-possible example to show it off.
https://github.com/jfairley/wdyr-lazy-bug
In this example, I have:
why-did-you-render
React.lazy
If I take away any of these 3 parts of the puzzle, the app renders without errors.
Realistically, the app doesn't always blow up, so simply disabling
why-did-you-render
unless explicitly needed to debug a dev scenario was the solution for me. I understand that the issue is some confluence of timing between the lazy import / initialization ofwhy-did-you-render
, the lazy import of components (viaReact.lazy
), and obviously the intentional delay of rendering downstream components, but as I said, my app is complicated, so these things are immovable objects unfortunately.Anyway, please have a look and thanks!
The text was updated successfully, but these errors were encountered: