Skip to content

Commit 5b7449f

Browse files
committed
chore: use react-scan on dev
1 parent 36d6d65 commit 5b7449f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/docs/app/root.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isRouteErrorResponse, Links, Meta, Outlet, Scripts, ScrollRestoration } from 'react-router'
1+
import { isRouteErrorResponse, Links, Meta, Outlet, Scripts, ScrollRestoration, useRouteLoaderData } from 'react-router'
22

33
import type { Route } from './+types/root'
44
import appInlineCss from './app.css?inline'
@@ -30,14 +30,23 @@ export const links: Route.LinksFunction = () => [
3030
},
3131
]
3232

33+
export async function loader() {
34+
return {
35+
isDev: import.meta.env.DEV,
36+
}
37+
}
38+
3339
export function Layout({ children }: { children: React.ReactNode }) {
40+
const data = useRouteLoaderData<typeof loader>('root')
41+
const useReactScan = data?.isDev === true
3442
return (
3543
<html lang="en">
3644
<head>
3745
<meta charSet="utf-8" />
3846
<meta name="viewport" content="width=device-width, initial-scale=1" />
3947
<Meta />
4048
<Links />
49+
{useReactScan && <script crossOrigin="anonymous" src="//unpkg.com/react-scan/dist/auto.global.js" />}
4150
<style id="app_css" dangerouslySetInnerHTML={{ __html: appInlineCss }} />
4251
</head>
4352
<body>

0 commit comments

Comments
 (0)