You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simplify JotaiDevTools implementation by removing lazy loading and Suspense wrapper
Fix DevTools state visibility issue by directly importing and rendering component
Set default dark theme in component props for consistency
Remove unnecessary store and theme props from component usage
Diagram Walkthrough
flowchart LR
A["Lazy loading with Suspense"] -->|Remove| B["Direct DevTools import"]
C["Manual theme prop passing"] -->|Simplify| D["Default dark theme"]
E["Complex Promise.all import"] -->|Refactor| F["Simple CSS import"]
B --> G["Fixed state visibility"]
D --> G
Loading
File Walkthrough
Relevant files
Bug fix
jotai-devtools.tsx
Simplify DevTools implementation and fix state visibility
src/base/components/dev/jotai-devtools.tsx
Removed lazy loading wrapper and Suspense component that was causing state visibility issues
Changed to direct import of DevTools component from jotai-devtools
Added default 'dark' theme prop to component signature
Simplified CSS import to conditional statement based on DEV environment
Use the useStore hook to get the correct store from the context and pass it to the DevTools component, ensuring it inspects the correct provider-scoped store.
+import { useStore } from 'jotai'+
export function JotaiDevTools({ theme = 'dark', ...props }: DevToolsProps) {
- if (!import.meta.env.DEV) return null;- return <DevTools theme={theme} {...props} />;+ const store = useStore()+ if (!import.meta.env.DEV) return null+ return <DevTools store={store} theme={theme} {...props} />
}
Apply / Chat
Suggestion importance[1-10]: 9
__
Why: This fixes a critical bug where the devtools would inspect the default Jotai store instead of the one provided by the <Provider>, rendering the tool ineffective in this context.
High
General
Isolate development code for better tree-shaking
Isolate development-only code into a separate file (jotai-devtools.dev.tsx) and export a dummy component for production builds to improve tree-shaking.
+// In a new file: src/base/components/dev/jotai-devtools.dev.tsx
import { DevTools, DevToolsProps } from 'jotai-devtools';
--if (import.meta.env.DEV) import('jotai-devtools/styles.css');+import 'jotai-devtools/styles.css';
export function JotaiDevTools({ theme = 'dark', ...props }: DevToolsProps) {
- if (!import.meta.env.DEV) return null;
return <DevTools theme={theme} {...props} />;
}
+// In the modified file: src/base/components/dev/jotai-devtools.tsx+import { DevToolsProps } from 'jotai-devtools';++// This component will be used in production builds and will be tree-shaken.+// eslint-disable-next-line @typescript-eslint/no-unused-vars+export function JotaiDevTools(props: DevToolsProps) {+ return null;+}+
Apply / Chat
Suggestion importance[1-10]: 6
__
Why: The suggestion proposes a more robust architectural pattern for tree-shaking development-only tools, which can improve build optimization and maintainability over the current implementation.
Low
Handle CSS import errors
Add a .catch() handler to the dynamic import of jotai-devtools/styles.css to prevent unhandled promise rejections on loading failure.
Why: The suggestion improves robustness by handling potential network errors during the dynamic import of CSS, which is good practice for development-time tooling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
closes #72
PR Type
Bug fix, Enhancement
Description
Simplify JotaiDevTools implementation by removing lazy loading and Suspense wrapper
Fix DevTools state visibility issue by directly importing and rendering component
Set default dark theme in component props for consistency
Remove unnecessary store and theme props from component usage
Diagram Walkthrough
File Walkthrough
jotai-devtools.tsx
Simplify DevTools implementation and fix state visibilitysrc/base/components/dev/jotai-devtools.tsx
state visibility issues
environment
syntax-editor-root.tsx
Remove explicit props from DevTools usagesrc/features/syntax-editor/pages/syntax-editor-root.tsx
usage