Compare commits

...

5 Commits

Author SHA1 Message Date
daishi
b5845a9daa 5.0.6 2025-06-26 23:09:15 +09:00
Daishi Kato
4a5e814a0e
chore: update dev dependencies (#3159)
* chore: update dev dependencies

* downgrade plugin-typescript
2025-06-26 23:07:40 +09:00
Wonsuk Choi
e639587da1
docs(README): remove 'omit' in 'Overwriting state' section (#3160)
* docs(README): replace 'lodash' with 'es-toolkit' in 'Overwriting state' section

* docs(README): change 'es-tooklit/compat' to 'es-toolkit/compat/omit'

* docs(README): replace 'es-toolkit' with custom 'omit' implementation

* docs(README): remove 'omit' util function

* docs(README): simplify 'deleteTuna'
2025-06-25 11:17:14 +09:00
Wonsuk Choi
5bc717b663
refactor(middleware): replace export * with explicit named and type exports (#3151)
Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
2025-06-23 12:41:54 +09:00
Vladimir Chirikov
ca08a5ebf9
perf(devtools): avoid inferring action type when explicit action name is provided (#3147)
Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
2025-06-23 12:17:41 +09:00
6 changed files with 936 additions and 794 deletions

View File

@ -19,8 +19,8 @@ jobs:
- 18.3.1
- 19.0.0
- 19.1.0
- 19.2.0-canary-c4676e72-20250520
- 0.0.0-experimental-c4676e72-20250520
- 19.2.0-canary-06e89951-20250620
- 0.0.0-experimental-06e89951-20250620
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4

View File

@ -125,13 +125,11 @@ const treats = useBearStore(
The `set` function has a second argument, `false` by default. Instead of merging, it will replace the state model. Be careful not to wipe out parts you rely on, like actions.
```jsx
import omit from 'lodash-es/omit'
const useFishStore = create((set) => ({
salmon: 1,
tuna: 2,
deleteEverything: () => set({}, true), // clears the entire store, actions included
deleteTuna: () => set((state) => omit(state, ['tuna']), true),
deleteTuna: () => set(({ tuna, ...rest }) => rest, true),
}))
```

View File

@ -3,7 +3,7 @@
"description": "🐻 Bear necessities for state management in React",
"private": true,
"type": "commonjs",
"version": "5.0.5",
"version": "5.0.6",
"main": "./index.js",
"types": "./index.d.ts",
"typesVersions": {
@ -116,45 +116,45 @@
"homepage": "https://github.com/pmndrs/zustand",
"packageManager": "pnpm@9.15.5",
"devDependencies": {
"@eslint/js": "^9.27.0",
"@eslint/js": "^9.29.0",
"@redux-devtools/extension": "^3.3.0",
"@rollup/plugin-alias": "^5.1.1",
"@rollup/plugin-node-resolve": "^16.0.1",
"@rollup/plugin-replace": "^6.0.2",
"@rollup/plugin-typescript": "^12.1.2",
"@rollup/plugin-typescript": "12.1.2",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.3.0",
"@types/node": "^22.15.21",
"@types/react": "^19.1.4",
"@types/react-dom": "^19.1.5",
"@types/node": "^24.0.3",
"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",
"@types/use-sync-external-store": "^1.5.0",
"@vitest/coverage-v8": "^3.1.4",
"@vitest/eslint-plugin": "^1.2.0",
"@vitest/ui": "^3.1.4",
"esbuild": "^0.25.4",
"eslint": "9.27.0",
"eslint-import-resolver-typescript": "^4.3.5",
"eslint-plugin-import": "^2.31.0",
"@vitest/coverage-v8": "^3.2.4",
"@vitest/eslint-plugin": "^1.2.7",
"@vitest/ui": "^3.2.4",
"esbuild": "^0.25.5",
"eslint": "9.29.0",
"eslint-import-resolver-typescript": "^4.4.3",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-jest-dom": "^5.5.0",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "6.0.0-rc.1",
"eslint-plugin-testing-library": "^7.2.1",
"eslint-plugin-testing-library": "^7.5.3",
"immer": "^10.1.1",
"jsdom": "^26.1.0",
"json": "^11.0.0",
"prettier": "^3.5.3",
"prettier": "^3.6.0",
"react": "19.1.0",
"react-dom": "19.1.0",
"redux": "^5.0.1",
"rollup": "^4.41.0",
"rollup": "^4.44.0",
"rollup-plugin-esbuild": "^6.2.1",
"shelljs": "^0.10.0",
"shx": "^0.4.0",
"tslib": "^2.8.1",
"typescript": "^5.8.3",
"typescript-eslint": "^8.32.1",
"typescript-eslint": "^8.34.1",
"use-sync-external-store": "^1.5.0",
"vitest": "^3.1.4"
"vitest": "^3.2.4"
},
"peerDependencies": {
"@types/react": ">=18.0.0",

1657
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,16 @@
export * from './middleware/redux.ts'
export * from './middleware/devtools.ts'
export * from './middleware/subscribeWithSelector.ts'
export * from './middleware/combine.ts'
export * from './middleware/persist.ts'
export { redux } from './middleware/redux.ts'
export {
devtools,
type DevtoolsOptions,
type NamedSet,
} from './middleware/devtools.ts'
export { subscribeWithSelector } from './middleware/subscribeWithSelector.ts'
export { combine } from './middleware/combine.ts'
export {
persist,
createJSONStorage,
type StateStorage,
type StorageValue,
type PersistStorage,
type PersistOptions,
} from './middleware/persist.ts'

View File

@ -207,10 +207,14 @@ const devtoolsImpl: DevtoolsImpl =
;(api.setState as any) = ((state, replace, nameOrAction: Action) => {
const r = set(state, replace as any)
if (!isRecording) return r
const inferredActionType = findCallerName(new Error().stack)
const action: { type: string } =
nameOrAction === undefined
? { type: anonymousActionType || inferredActionType || 'anonymous' }
? {
type:
anonymousActionType ||
findCallerName(new Error().stack) ||
'anonymous',
}
: typeof nameOrAction === 'string'
? { type: nameOrAction }
: nameOrAction