Skip to content

Commit 7eee65b

Browse files
authored
fix: fix wdyr issues with hooks order (#167)
1 parent a559922 commit 7eee65b

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import './wdyr';
1+
if (import.meta.env.DEV) {
2+
import.meta.glob('./wdyr.ts', { eager: true });
3+
}
24
import React from 'react';
35
import { createRoot } from 'react-dom/client';
46
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';

src/wdyr.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import React from 'react';
2+
import whyDidYouRender from '@welldone-software/why-did-you-render';
23

3-
if (import.meta.env.DEV) {
4-
const { default: whyDidYouRender } = await import('@welldone-software/why-did-you-render');
5-
6-
whyDidYouRender(React, {
7-
trackHooks: true,
8-
trackAllPureComponents: true,
9-
});
10-
}
4+
whyDidYouRender(React, {
5+
trackHooks: true,
6+
trackAllPureComponents: true,
7+
});

0 commit comments

Comments
 (0)