-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathwdyr.js
More file actions
23 lines (19 loc) · 907 Bytes
/
wdyr.js
File metadata and controls
23 lines (19 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* eslint-disable import-x/no-commonjs */
// Initialization for why-did-you-render in React Native/Expo
// Must be imported as early as possible from the entry file in development only
// Important: Metro/Hermes console doesn't support console.group well. Use onlyLogs to avoid grouping.
// Also, track react-redux useSelector to see hook diffs.
export const shouldEnableWhyDidYouRender = () =>
__DEV__ && process.env.ENABLE_WHY_DID_YOU_RENDER === 'true';
if (shouldEnableWhyDidYouRender()) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const React = require('react');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const whyDidYouRender = require('@welldone-software/why-did-you-render');
// eslint-disable-next-line no-console
console.log('[WDYR] initializing');
whyDidYouRender(React, {
trackAllPureComponents: true,
onlyLogs: true,
});
}