40 Commits

Author SHA1 Message Date
Marcin Kulpa
f689d78a31
test: incorporate eslint-plugin-testing-library and fix reported issues (#2844) 2024-11-09 09:46:15 +09:00
Marcin Kulpa
dcc4c098ab
test: use screen exposed by React Testing Library (#2832) 2024-11-04 13:17:52 +09:00
Daishi Kato
e247220ece
v5 (#2138)
* prepare for the next major version

* [v5] breaking: drop default exports (#2238)

* fix: drop default exports for v5

* chore: remove default from cjs build

* refactor: export shallow in v5

* fix: remove `addModuleExport` option for cjs.

* [v5] breaking: drop deprecated features (#2235)

* fix: remove deprecated v4 features

* chore(build): remove context

* docs(typescript): remove deprecated equals api

* docs(persist): remove old persist api

* chore: run yarn prettier on typescript docs

* Discard changes to docs/guides/typescript.md

* Discard changes to docs/integrations/persisting-store-data.md

* Discard changes to tests/shallow.test.tsx

* Discard changes to tests/vanilla/subscribe.test.tsx

* [v5] breaking: make React 18 as minimal requirement (#2236)

* fix: update package.json to require react 18+

* chore: update github actions to test on react 18+

* chore: remove devtools-skip hack from actions

* chore(test): remove CI-SKIP from devtools tests

* [v5] breaking: make use-sync-external-store an optional peer dependency (#2237)

* chore: make use-sync-external-store optional peerDep

* fix: use correct versions in package.json

* [v5] breaking: require TypeScript 4.5 and update tests (#2257)

* breaking(types): TS requirement

* wip: latest only

* wip: latest only 2

* drop ts <4.4

* wip: do not skip lib checkes

* use latest node types

* drop ts 4.4

* [v5]: drop "module" condition  (#2270)

* Update package json in order to remove module

* Update rollup config in order to remove module config

* Update patch esm script

* Update package json to general exports and update node version (#2272)

* [v5]: drop UMD/SystemJS builds (#2287)

* Update rollup config in order to drop system js and umd builds

* Update packages

* Clean up files

* Update rollup config

* Update gh workflows

* Minor fixes

* Minor fixes

* Minor fixes

* Minor fixes

* Testing

* Minor changes

* Minor fixes

* remove `WithReact` type (#2300)

* 5.0.0-alpha.0

* [v5]: do not depend on use-sync-external-store (#2301)

* [v5]: do not depend on use-sync-external-store

* memo get(server)snapshot

* 5.0.0-alpha.1

* [v5]: refactor useMemoSelector (#2302)

* [v5]: refactor useMemoSelector

* add a test

* Revert "[v5]: refactor useMemoSelector"

This reverts commit b3c8b15586a270d12c335e566975021adf86c815.

* Revert "Revert "[v5]: refactor useMemoSelector""

This reverts commit 3c47301d23e18dffb7d72df36595f83570d15d08.

* [v5]: separate react entry point (#2303)

* 5.0.0-alpha.2

* 5.0.0-alpha.3

* refactor: Switch to Object.hasOwn (#2365)

* [v5] drop es5 (#2380)

* update yarn lock

* 5.0.0-alpha.4

* [v5]: follow React "standard" way with breaking behavioral change (#2395)

* [v5]: follow React "standard" way with breaking behavioral change

* add test

* 5.0.0-alpha.5

* [v5] Rewrite shallow to support iterables (#2427)

* [v5] fix rollup config for cjs (#2433)

* 5.0.0-alpha.6

* no production build test

* recover types that are dropped in #2462

* remove unused replacement

* [v5] Remove Devtools warning (#2466)

* chore: remove devtools extension warning

* docs: add devtools link to readme

* chore: remove unused test

* chrome: remove unused tests

* chore: remove unused test

* Revert "chore: remove unused test"

This reverts commit 0fa2a75f4936d960f703bf19e8f3505962cd628e.

* update test name

* update pnpm lock

* fix merge main

* add migration guide

* fix typos

* 5.0.0-beta.0

* update migration doc

* fix merge main

* fix merge main (prettier)

* 5.0.0-beta.1

* fix(types)!: require complete state if `setState`'s `replace` flag is set (#2580)

* fix(types): require complete state if `setState`'s `replace` flag is set

* switch to variant 2

* fix type errors

* update setState types for devtools and immer

* make devtools setState non-generic

* add migration guide

* merge migration guides

* run prettier

* Update tests/middlewareTypes.test.tsx

---------

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
Co-authored-by: daishi <daishi@axlight.com>

* 5.0.0-beta.2

* move v5 migration doc

* fix ci

* missing commmit

* remove unused rule exclusion

* comment about react compiler

* revert eslint config

---------

Co-authored-by: Charles Kornoelje <33156025+charkour@users.noreply.github.com>
Co-authored-by: Danilo Britto <dbritto.dev@gmail.com>
Co-authored-by: Ekin Dursun <ekindursun@gmail.com>
Co-authored-by: Simon Farshid <simon.farshid@outlook.com>
2024-08-16 09:41:00 +09:00
Daishi Kato
66f3a029fb
chore: enable verbatimModuleSyntax in tsconfig (#2649) 2024-07-20 17:15:21 +09:00
Dominik Dorfmeister
740033cf31
feat: getInitialState (#2277)
* feat(react): implement getServerState by closing over the defaultState

serverState will be used by react on the first client render; this should avoid hydration mismatches when combined with the persist middleware, which can change the state between the SSR and the first CSR

* define getServerState in vanilla.ts

* feat: implement getServerResult in persist middleware

this avoids hydration errors when state is restored from e.g. localstorage synchronously

* feat: capture initialState for getServerState in react

this avoids hydration mismatches when updates happen to the store state between ssr and csr

* refactor: revert changes to oldImpl

* fix: make selector default to identity function

if we default to `api.getState`, we will always read the client snapshot if there is no selector passed. An identity function returns its argument, which is either the snapshot (api.getState) or the server snapshot (api.getServerState)

* define getInitialState in vanilla

* revert WithReact

* fix them

* fix test

* oops, fix another test too

* forgot to use identity

* test: add a test for hydration errors

* fix(readme): imply getInitialState is a public api

---------

Co-authored-by: daishi <daishi@axlight.com>
2024-01-20 09:05:58 +09:00
Daishi Kato
9857a676a9
refactor: revisit prettier config to be minimal (#2193) 2023-11-14 12:19:51 +09:00
Daishi Kato
c6900a4562
feat: deprecate equalityFn and add createWithEqualityFn (#1945)
* feat: deprecate equalityFn and add createWithEqualityFn

* add link to deprecation message
2023-08-01 10:15:09 +09:00
Arjun Vegda
496a466c2c
chore(tests): migrate to vitest (#1753)
* test: migrate to vitest

* test: try #1 remove CI-MATRIX tags

* test: try 2 remove import/require replace

* chore: remove unused scripts/assignments

* chore(test-multiple-builds.yml): remove import/require replace script

* fix merging main

---------

Co-authored-by: daishi <daishi@axlight.com>
2023-05-04 13:25:24 +09:00
Daishi Kato
9062ca634f
chore: remove __DEV__ with ts-jest (#1598)
* wip: use ts-jest instead of swc/jest

* use esm in jest

* remove types/jest

* remove __DEV__

* fix rollup config

* fix github workflow

* hack jest.Mock

* wip: ts

* skipLibCheck for older ts 2

* wip: ts

* wip: workflow...

* wip: workflow...

* wip: workflow...

* experiment...

* experiment...2

* experiment...3

* experiment...4

* jest preset
2023-02-10 19:05:12 +09:00
Daishi Kato
0b55a3d74b
feat: deprecate default export (#1514) 2023-01-10 18:13:25 +09:00
Daishi Kato
a576b3c968
chore(deps): update dev dependencies (#1351)
* chore(deps): update dev dependencies

* tweak a workflow file
2022-10-09 14:36:32 +09:00
huangcheng
ae4cc7f1b1
fix: should use Object.is to compare two value (#1314) 2022-10-09 10:10:37 +09:00
Daishi Kato
b3dc3d64b2
chore(tests): enable StrictMode as much as possible (#1262) 2022-09-05 13:48:59 +09:00
Daishi Kato
c60a535a46
feat(vanilla): non-object state (#1144)
* feat: non-object state

* add test

* prefer unknown

* fix types for persist and subscribeWithSelector

* no Cast in persist and subscribeWithSelector

* simplify immer type

* simplify devtools type

* simplify redux type

* simplify type with looser action

* fix StoreApi type parameter

* fix types
2022-08-19 07:47:10 +09:00
Łukasz Rabiec
75d0886cd6
chore(tests): remove imperfectly working test added in #276 (#1184)
* used createRoot in test

* Removed unused test
2022-08-17 22:56:23 +09:00
Daishi Kato
fa581ddd9b
fix(docs): useBoundStore instead of useStore (#1125)
* fix(docs): useBoundStore instead of useStore

* run prettier
2022-07-26 08:58:43 +09:00
Daishi Kato
a4b08a10f3
refactor(types): avoid using deprecated types in tests (#1126) 2022-07-25 18:54:32 +09:00
Daishi Kato
060c092694
fix(types): use TS interfaces only for public api (#1106) 2022-07-20 08:48:43 +09:00
Daishi Kato
3d764b0a4a
refactor: prefer interfaces (#1012) 2022-06-18 22:43:25 +09:00
Daishi Kato
a34649d35a
feat: use-sync-external-store (#550)
* imaginary code that uses uSES

* revert backward compatibility code as this is not going to be v4

* use use-sync-external-store

* revert to react 17

* handle error by our own

* v4.0.0-alpha.2

* fix&refactor a bit

* update uSES experimental package

* remove error propagation hack

* update size snapshot

* update uSES and add dts

* split react.ts and no export wild

* split useStore impl

* context to follow the new api, export wild again

* v4.0.0-alpha.3

* add missing await

* update uSES

* update uSES

* uses uSES extra!

* v4.0.0-alpha.3

* update uSES

* fix update uSES

* v4.0.0-alpha.5

* add useDebugValue

* update uSES

* update uSES types

* update uSES

* v4.0.0-alpha.6

* fix(readme): remove memoization section which is no longer valid with uSES

* feat(readme): add new createStore/useStore usage

* update useSES

* update uSES and deps

* v4.0.0-alpha.7

* update uSES

* update uSES

* shave bytes

* update uSES

* fix yarn lock

* temporary fix #829

* uSES rc.1

* getServerState for #886, no types yet

* uSES v1
2022-04-07 23:53:27 +09:00
Daishi Kato
30f5505cdb
chore(eslint): add recommended rules and etc (#678) 2021-11-25 22:33:59 +09:00
Daishi Kato
10cb45c201
feat(types): better middleware support (#601)
* feat(types): better middleware support

* some more trial

* some more trial

* Revert "some more trial"

This reverts commit c54bf7cb75faa58e6df4325679ea5f815b594d01.

* some more trial

* some more trial

* some more trial

* some more trial

* Revert "some more trial"

This reverts commit 3aef9e229a54f18a901a1aea557cb05b46e8f2ab.

* some more trial

* Revert "some more trial"

This reverts commit fce0cb4c3e012adb35e5240e64d31cde3f7790f8.

* some more trial

* some more trial

* some more trial

* some more trial

* add redux middleware type test

* fix with type alias

* add devtools and redux combination test

* combine to support named set

* remove duplicated types
2021-10-21 17:51:24 +09:00
Daishi Kato
12b6111399
refactor(tests): cleaner tests (#580) 2021-10-03 14:52:25 +09:00
Daishi Kato
ae86695c44
refactor(test): use aliases (#571) 2021-09-29 00:55:12 +09:00
Daishi Kato
2a412500f5
refactor: stricter tsconfig (#544)
* refactor: stricter tsconfig

* update typescript
2021-09-11 21:55:21 +09:00
Daishi Kato
e47ea038fd
chore: update eslintrc and use react-jsx (#531) 2021-08-15 19:44:06 +09:00
Benjamin Arbogast
d6fa004c66
Move some tests out of basic.test.tsx into separate files (#424) 2021-06-09 19:28:20 +09:00
Benjamin Arbogast
b259c2a89c
Remove usage of any from tests (#417)
* Remove usage of `any` from tests

* Improve

* Improve

* Replace @ts-ignore with @ts-expect-error

* Fix TS errors

* Apply suggested solution to 'can get the store'

* Remove any from 'can set store' (TS doesn't like it, though)

* Yay

* Use more precise type
2021-06-09 07:44:59 +09:00
Benjamin Arbogast
d2a587c51a
Remove unnecessary console.error mocks from tests (#420)
... and move one necessary one into the describe() block
2021-06-08 17:32:12 +09:00
Dominik Dorfmeister
9246dcec52
(types): improve types for setState (#397)
* (types): improve types for setState

allow for passing multiple key generics to PartialState; this will make sure that we can have paths in the PartialState setter function that return different keys

* (types): improve types for setState

replace `name` with `something`. for some reason, the property `name` does not yield errors :/

* (types): improve types for setState

streamline generic default values in middleware.ts with those in vanilla.ts

* (types): improve types for setState

use generic type S instead of State (S extends State)
2021-06-05 06:59:00 +09:00
daishi
9d3a701e88 chore: rename to pmndrs from react-spring 2021-05-06 00:13:56 +09:00
Andrey Goncharov
f43d1127ee
fix: remove mandatory index signature (#376)
* Remove undesired index signature

* Use type assertion

* Update TypeScript readme

* Update TypeScript readme

* Replace Record with object

* Remove unnecessary keyof

* Minor fixes
2021-05-05 21:34:51 +09:00
Dominik Dorfmeister
52e6448602
(types): improve types for setState (#320)
* (types): improve types for setState

instead of using Partial, which would allow setting every field to undefined, we infer the types of the values depending on the keys passed into the set function

* (types): improve types for setState

add code comment to clarify why we are using Pick<T, K> | T

* (types): improve types for setState

apply the same changes we did for SetState also to namedSet for the devtools middleware

* (types): improve types for setState

tests for the partial logic

* empty commit

Co-authored-by: daishi <daishi@axlight.com>
2021-02-28 10:35:39 +09:00
Leonardo Guarnieri de Bastiani
ba0396ab67
feat: works with useLayoutEffect (#280)
* feat: works with useLayoutEffect

* Feedback applied

* Added cleanup
2021-01-10 21:00:51 +09:00
Rafał Pysz
58c286e6cb
fixed an issue in type infering while using eq function in hooks (#266)
* fixed an issue in type infering while using eq function in hooks

* moving back quotes removed by autoformatter

* tweaked test and run linter

* Update tests/basic.test.tsx

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
2020-12-31 19:15:54 +09:00
Sebastiaan ten Pas
38ddba491a
Expose previous value in subscribe (#241) 2020-11-16 23:12:20 +09:00
Daishi Kato
ca63289543
add equality check test (#237) 2020-11-16 20:04:07 +09:00
daishi
af8ea59582 fix tests with toHaveBeenCalled as suggested in #234 2020-11-08 12:48:34 +09:00
daishi
6d8e7ab206 fix eslint warnings in tests 2020-11-08 11:49:26 +09:00
daishi
5ad795d5ca rename to basic.test.tsx 2020-09-12 09:20:57 +09:00