mirror of
https://github.com/pmndrs/zustand.git
synced 2025-12-08 19:45:52 +00:00
Compare commits
5 Commits
a6143e0f23
...
b5845a9daa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5845a9daa | ||
|
|
4a5e814a0e | ||
|
|
e639587da1 | ||
|
|
5bc717b663 | ||
|
|
ca08a5ebf9 |
4
.github/workflows/test-multiple-versions.yml
vendored
4
.github/workflows/test-multiple-versions.yml
vendored
@ -19,8 +19,8 @@ jobs:
|
|||||||
- 18.3.1
|
- 18.3.1
|
||||||
- 19.0.0
|
- 19.0.0
|
||||||
- 19.1.0
|
- 19.1.0
|
||||||
- 19.2.0-canary-c4676e72-20250520
|
- 19.2.0-canary-06e89951-20250620
|
||||||
- 0.0.0-experimental-c4676e72-20250520
|
- 0.0.0-experimental-06e89951-20250620
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
|
|||||||
@ -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.
|
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
|
```jsx
|
||||||
import omit from 'lodash-es/omit'
|
|
||||||
|
|
||||||
const useFishStore = create((set) => ({
|
const useFishStore = create((set) => ({
|
||||||
salmon: 1,
|
salmon: 1,
|
||||||
tuna: 2,
|
tuna: 2,
|
||||||
deleteEverything: () => set({}, true), // clears the entire store, actions included
|
deleteEverything: () => set({}, true), // clears the entire store, actions included
|
||||||
deleteTuna: () => set((state) => omit(state, ['tuna']), true),
|
deleteTuna: () => set(({ tuna, ...rest }) => rest, true),
|
||||||
}))
|
}))
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
36
package.json
36
package.json
@ -3,7 +3,7 @@
|
|||||||
"description": "🐻 Bear necessities for state management in React",
|
"description": "🐻 Bear necessities for state management in React",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"version": "5.0.5",
|
"version": "5.0.6",
|
||||||
"main": "./index.js",
|
"main": "./index.js",
|
||||||
"types": "./index.d.ts",
|
"types": "./index.d.ts",
|
||||||
"typesVersions": {
|
"typesVersions": {
|
||||||
@ -116,45 +116,45 @@
|
|||||||
"homepage": "https://github.com/pmndrs/zustand",
|
"homepage": "https://github.com/pmndrs/zustand",
|
||||||
"packageManager": "pnpm@9.15.5",
|
"packageManager": "pnpm@9.15.5",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.27.0",
|
"@eslint/js": "^9.29.0",
|
||||||
"@redux-devtools/extension": "^3.3.0",
|
"@redux-devtools/extension": "^3.3.0",
|
||||||
"@rollup/plugin-alias": "^5.1.1",
|
"@rollup/plugin-alias": "^5.1.1",
|
||||||
"@rollup/plugin-node-resolve": "^16.0.1",
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
||||||
"@rollup/plugin-replace": "^6.0.2",
|
"@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/jest-dom": "^6.6.3",
|
||||||
"@testing-library/react": "^16.3.0",
|
"@testing-library/react": "^16.3.0",
|
||||||
"@types/node": "^22.15.21",
|
"@types/node": "^24.0.3",
|
||||||
"@types/react": "^19.1.4",
|
"@types/react": "^19.1.8",
|
||||||
"@types/react-dom": "^19.1.5",
|
"@types/react-dom": "^19.1.6",
|
||||||
"@types/use-sync-external-store": "^1.5.0",
|
"@types/use-sync-external-store": "^1.5.0",
|
||||||
"@vitest/coverage-v8": "^3.1.4",
|
"@vitest/coverage-v8": "^3.2.4",
|
||||||
"@vitest/eslint-plugin": "^1.2.0",
|
"@vitest/eslint-plugin": "^1.2.7",
|
||||||
"@vitest/ui": "^3.1.4",
|
"@vitest/ui": "^3.2.4",
|
||||||
"esbuild": "^0.25.4",
|
"esbuild": "^0.25.5",
|
||||||
"eslint": "9.27.0",
|
"eslint": "9.29.0",
|
||||||
"eslint-import-resolver-typescript": "^4.3.5",
|
"eslint-import-resolver-typescript": "^4.4.3",
|
||||||
"eslint-plugin-import": "^2.31.0",
|
"eslint-plugin-import": "^2.32.0",
|
||||||
"eslint-plugin-jest-dom": "^5.5.0",
|
"eslint-plugin-jest-dom": "^5.5.0",
|
||||||
"eslint-plugin-react": "^7.37.5",
|
"eslint-plugin-react": "^7.37.5",
|
||||||
"eslint-plugin-react-hooks": "6.0.0-rc.1",
|
"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",
|
"immer": "^10.1.1",
|
||||||
"jsdom": "^26.1.0",
|
"jsdom": "^26.1.0",
|
||||||
"json": "^11.0.0",
|
"json": "^11.0.0",
|
||||||
"prettier": "^3.5.3",
|
"prettier": "^3.6.0",
|
||||||
"react": "19.1.0",
|
"react": "19.1.0",
|
||||||
"react-dom": "19.1.0",
|
"react-dom": "19.1.0",
|
||||||
"redux": "^5.0.1",
|
"redux": "^5.0.1",
|
||||||
"rollup": "^4.41.0",
|
"rollup": "^4.44.0",
|
||||||
"rollup-plugin-esbuild": "^6.2.1",
|
"rollup-plugin-esbuild": "^6.2.1",
|
||||||
"shelljs": "^0.10.0",
|
"shelljs": "^0.10.0",
|
||||||
"shx": "^0.4.0",
|
"shx": "^0.4.0",
|
||||||
"tslib": "^2.8.1",
|
"tslib": "^2.8.1",
|
||||||
"typescript": "^5.8.3",
|
"typescript": "^5.8.3",
|
||||||
"typescript-eslint": "^8.32.1",
|
"typescript-eslint": "^8.34.1",
|
||||||
"use-sync-external-store": "^1.5.0",
|
"use-sync-external-store": "^1.5.0",
|
||||||
"vitest": "^3.1.4"
|
"vitest": "^3.2.4"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@types/react": ">=18.0.0",
|
"@types/react": ">=18.0.0",
|
||||||
|
|||||||
1657
pnpm-lock.yaml
generated
1657
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,16 @@
|
|||||||
export * from './middleware/redux.ts'
|
export { redux } from './middleware/redux.ts'
|
||||||
export * from './middleware/devtools.ts'
|
export {
|
||||||
export * from './middleware/subscribeWithSelector.ts'
|
devtools,
|
||||||
export * from './middleware/combine.ts'
|
type DevtoolsOptions,
|
||||||
export * from './middleware/persist.ts'
|
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'
|
||||||
|
|||||||
@ -207,10 +207,14 @@ const devtoolsImpl: DevtoolsImpl =
|
|||||||
;(api.setState as any) = ((state, replace, nameOrAction: Action) => {
|
;(api.setState as any) = ((state, replace, nameOrAction: Action) => {
|
||||||
const r = set(state, replace as any)
|
const r = set(state, replace as any)
|
||||||
if (!isRecording) return r
|
if (!isRecording) return r
|
||||||
const inferredActionType = findCallerName(new Error().stack)
|
|
||||||
const action: { type: string } =
|
const action: { type: string } =
|
||||||
nameOrAction === undefined
|
nameOrAction === undefined
|
||||||
? { type: anonymousActionType || inferredActionType || 'anonymous' }
|
? {
|
||||||
|
type:
|
||||||
|
anonymousActionType ||
|
||||||
|
findCallerName(new Error().stack) ||
|
||||||
|
'anonymous',
|
||||||
|
}
|
||||||
: typeof nameOrAction === 'string'
|
: typeof nameOrAction === 'string'
|
||||||
? { type: nameOrAction }
|
? { type: nameOrAction }
|
||||||
: nameOrAction
|
: nameOrAction
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user