Closed timothyarmes closed 4 years ago
you need to make sure you call whyDidYouRender(React);
as soon as possible, before you do anything else.
Sorry, I pressed save before entering all the information. I've updated my report and included a small project to demonstrate the issue.
The bug happens because react-loadable
does some unusual React work as soon as it is imported and we got to run whyDidYouRender
even earlier.
I got to fix it by importing ./wdyr
like this in Main.jsx
:
import './wdyr';
import React from 'react';
import { Meteor } from 'meteor/meteor';
import { render } from 'react-dom';
import Loadable from '/imports/ui/Loadable'
Meteor.startup(() => {
render(<Loadable />, document.getElementById('react-target'));
});
Where wdyr.jsx
looks like this:
import React from 'react';
import { Meteor } from 'meteor/meteor';
if (Meteor.isDevelopment && Meteor.isClient) {
const whyDidYouRender = require('@welldone-software/why-did-you-render/dist/no-classes-transpile/umd/whyDidYouRender.js');
whyDidYouRender(React);
}
Thank you!
I'm getting this following error when whyDidYouRender is installed:
Loadable is a fork of react-loadable for Meteor: https://github.com/CaptainN/npdev-react-loadable I've been through the Loadable source, but as far as I can tell there are no issues with hook order change. Futhermore, the bug only occurs when whyDidYouRender is installed.
Also worthy of note is that version 3.4.2 of whyDidYouRender works fine. It fails as of 3.5.0. I am calling whyDidYouRender as soon as possible.
I've created a very simple meteor project to replicate the issue:
http://www.timothyarmes.com/private/whyRenderBug.zip
Run with