File tree Expand file tree Collapse file tree 3 files changed +474
-3
lines changed
Expand file tree Collapse file tree 3 files changed +474
-3
lines changed Original file line number Diff line number Diff line change 1+ import { type ReactNode } from 'react'
2+ import { useEffect , useState } from 'react'
3+ import { createPortal } from 'react-dom'
4+
5+ export default function Devtools ( { jotai, reactQuery } : { jotai ?: boolean ; reactQuery ?: boolean } ) {
6+ const [ DevtoolsComponents , setDevtoolsComponents ] = useState < ReactNode | undefined > ( )
7+
8+ useEffect ( ( ) => {
9+ if ( import . meta. env . DEV ) {
10+ Promise . all ( [
11+ jotai ? import ( 'jotai-devtools' ) : undefined ,
12+ reactQuery ? import ( '@tanstack/react-query-devtools' ) : undefined ,
13+ jotai ? import ( 'jotai-devtools/styles.css' ) : undefined
14+ ] ) . then ( ( [ jotaiDevtools , reactQueryDevtools ] ) => {
15+ const DevelopmentToolsUI = (
16+ < >
17+ { jotai && jotaiDevtools ? < jotaiDevtools . DevTools position = "bottom-right" /> : undefined }
18+ { reactQuery && reactQueryDevtools ? (
19+ < reactQueryDevtools . ReactQueryDevtools initialIsOpen = { false } position = "bottom" />
20+ ) : undefined }
21+ </ >
22+ )
23+ setDevtoolsComponents ( DevelopmentToolsUI )
24+ } )
25+ }
26+ } , [ jotai , reactQuery ] )
27+
28+ if ( ! import . meta. env . DEV ) return
29+
30+ return DevtoolsComponents ? createPortal ( DevtoolsComponents , document . body ) : undefined
31+ }
Original file line number Diff line number Diff line change 4343 "immer" : " ^10.1.1" ,
4444 "jotai" : " ^2.8.3" ,
4545 "jotai-immer" : " ^0.4.1" ,
46+ "jotai-devtools" : " ^0.10.1" ,
4647 "localforage" : " ^1.10.0" ,
4748 "lucide-react" : " ^0.397.0" ,
4849 "react" : " ^18.3.1" ,
141142 "vite-tsconfig-paths" : " ^5.0.1" ,
142143 "vitest" : " ^1.6.0"
143144 }
144- }
145+ }
You can’t perform that action at this time.
0 commit comments