mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
fd1835ca5d
Phase 2 of the refactor plan in docs/ARCHITECTURE.md.
Install
- yarn add zustand (^5, matches React 19 peer requirement).
Wiring
- src/state/createNitroStore.ts: replaces the previous prototype
(which threw on call) with a re-export of zustand's `create` under
the project-local name `createNitroStore`. Comments document the
convention (one store per domain, subscribe to slices not the whole
store).
First migration target
- src/components/navigator/views/navigatorRoomCreatorStore.ts (new):
a Zustand store with `isCreating: boolean` and `beginCreate()` —
the latter latches the flag to true, dispatches an internal
setTimeout to auto-reset after 5s, and replaces any in-flight timer
on re-entry. The timer handle lives in the store's closure, so a
remount of the view doesn't reset the lockout and StrictMode's
double-mount no longer schedules two pending timers.
- src/components/navigator/views/NavigatorRoomCreatorView.tsx:
removes the two module-level `let` variables that the React Compiler
was flagging ("Writing to a variable defined outside a component is
not allowed"). The component now reads `isCreating` via a slice
subscription and calls `beginCreate()` from the click handler. The
imperative guard (`if (isCreating) return`) uses
`useRoomCreatorStore.getState()` so it reads the latest value
synchronously without being a stale closure.
- Also cleans up `FC<{}>` -> `FC` while touching the file.
Verification
- yarn eslint on the three touched files: 1 pre-existing error
(the `setCategory(categories[0].id)` set-state-in-effect on the
categories hook, deliberately left as-is in Phase C — it's the
"init from late-arriving async data" pattern; baseline matches).
- yarn tsc: clean.
Migration path (per docs/ARCHITECTURE.md)
- This is the smallest possible Zustand pilot (~30 lines), chosen
because the let-singleton anti-pattern was the most obvious quick
win and the React Compiler was already complaining about it.
- Next adoption targets (cross-feature UI state): the toolbar's
active-window state (currently inside scattered Contexts), the
notification center's open-state, the catalog's currentPage/selection
state (after the god-hook split).
https://claude.ai/code/session_01GrR87LAqnAEyKG2ZbmQt5Q
59 lines
2.0 KiB
JSON
59 lines
2.0 KiB
JSON
{
|
|
"name": "nitro-react",
|
|
"version": "2.2",
|
|
"homepage": ".",
|
|
"private": true,
|
|
"scripts": {
|
|
"prebuild": "node scripts/write-asset-loader.mjs",
|
|
"start": "vite --host",
|
|
"build": "vite build && node scripts/minify-dist.mjs",
|
|
"build:prod": "npx browserslist@latest --update-db && yarn build",
|
|
"eslint": "eslint ./src",
|
|
"typecheck": "tsgo --noEmit"
|
|
},
|
|
"dependencies": {
|
|
"@babel/runtime": "^7.29.2",
|
|
"@emoji-mart/data": "^1.2.1",
|
|
"@emoji-mart/react": "^1.1.1",
|
|
"@radix-ui/react-popover": "^1.1.15",
|
|
"@radix-ui/react-slider": "^1.3.6",
|
|
"@tanstack/react-query": "5",
|
|
"@tanstack/react-query-devtools": "5",
|
|
"@tanstack/react-virtual": "^3.13.24",
|
|
"dompurify": "^3.4.2",
|
|
"emoji-mart": "^5.6.0",
|
|
"emoji-toolkit": "10.0.0",
|
|
"framer-motion": "^12.38.0",
|
|
"react": "^19.2.5",
|
|
"react-dom": "^19.2.5",
|
|
"react-error-boundary": "^6.1.1",
|
|
"react-icons": "^5.6.0",
|
|
"react-player": "^2.16.0",
|
|
"use-between": "^1.4.0",
|
|
"zustand": "^5.0.13"
|
|
},
|
|
"devDependencies": {
|
|
"@tailwindcss/forms": "^0.5.11",
|
|
"@tailwindcss/postcss": "^4.2.4",
|
|
"@types/node": "^25.6.0",
|
|
"@types/react": "^19.2.14",
|
|
"@types/react-dom": "^19.2.3",
|
|
"@typescript-eslint/eslint-plugin": "^8.59.1",
|
|
"@typescript-eslint/parser": "^8.59.1",
|
|
"@typescript/native-preview": "^7.0.0-dev.20260509.2",
|
|
"@vitejs/plugin-react": "^6.0.1",
|
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
"eslint": "^10.2.1",
|
|
"eslint-plugin-react": "^7.37.5",
|
|
"eslint-plugin-react-compiler": "19.1.0-rc.2",
|
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
"postcss": "^8.5.12",
|
|
"postcss-nested": "^7.0.2",
|
|
"sass": "^1.99.0",
|
|
"tailwindcss": "^4.2.4",
|
|
"typescript": "^6.0.3",
|
|
"typescript-eslint": "^8.59.1",
|
|
"vite": "^8.0.10"
|
|
}
|
|
}
|