Skip to content

Commit 8387f3d

Browse files
fix: prevent duplicate printAppInfo output in StrictMode
Move printAppInfo() from a useEffect in the Root component to a top-level call in main.tsx. It is a one-time startup side effect, not tied to any component lifecycle, so it does not belong in React's render tree where StrictMode double-invokes effects.
1 parent 6212380 commit 8387f3d

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

src/main.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import ReactDOM from 'react-dom/client'
44

55
import NotFound404 from '@/src/components/pageComponents/NotFound404'
66
import { routeTree } from '@/src/routeTree.gen'
7+
import { printAppInfo } from '@/src/utils/printAppInfo'
78

89
const router = createRouter({
910
routeTree,
@@ -16,6 +17,8 @@ declare module '@tanstack/react-router' {
1617
}
1718
}
1819

20+
printAppInfo()
21+
1922
// biome-ignore lint/style/noNonNullAssertion: root element is guaranteed by index.html
2023
const rootElement = document.getElementById('root')!
2124

src/routes/__root.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { chakra, Flex } from '@chakra-ui/react'
22
import { createRootRoute, Outlet } from '@tanstack/react-router'
33
import { Analytics } from '@vercel/analytics/react'
4-
import { useEffect } from 'react'
54
import { TanStackReactQueryDevtools } from '@/src/components/sharedComponents/dev/TanStackReactQueryDevtools'
65
import { TanStackRouterDevtools } from '@/src/components/sharedComponents/dev/TanStackRouterDevtools'
76
import { Footer } from '@/src/components/sharedComponents/ui/Footer'
@@ -10,17 +9,11 @@ import { Provider } from '@/src/components/ui/provider'
109
import { Toaster } from '@/src/components/ui/toaster'
1110
import { TransactionNotificationProvider } from '@/src/providers/TransactionNotificationProvider'
1211
import { Web3Provider } from '@/src/providers/Web3Provider'
13-
import { printAppInfo } from '@/src/utils/printAppInfo'
14-
1512
export const Route = createRootRoute({
1613
component: Root,
1714
})
1815

1916
function Root() {
20-
useEffect(() => {
21-
printAppInfo()
22-
}, [])
23-
2417
return (
2518
<Provider>
2619
<Web3Provider>

0 commit comments

Comments
 (0)