* update vitest
* use resolve
* patch for older ts
* for older ts
* hack with any
* for other builds
* wip: for umd
* Revert "wip: for umd"
This reverts commit a5c0d6beaa80cbbdcad7961b77d593effd6a83c8.
* wip: esm
* wip: system
* Revert "wip: system"
This reverts commit aa919631a94a5b321fa9f2ec6c26b826c37ca3b0.
* wip: umd
* wip: hack cjs
* system cannot be tested
* Update third-party-libraries.md
* docs: order davstack store link alphabetically
* docs: add link to 3rd party autogenerated selectors library
* Update docs/integrations/third-party-libraries.md
change the dash
Co-authored-by: Blazej Sewera <code@sewera.dev>
---------
Co-authored-by: Blazej Sewera <code@sewera.dev>
Corepack chooses package manager to use with the
field `packageManager`. For users using Yarn
through Corepack, this is a real convenience.
Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
* updated readme with more examples
* moved example to docs from readme
* formatted code with Prettier
---------
Co-authored-by: Ankit Sagar <ankit.sagar@telnesstech.com>
Right now, we're requiring new `StateStorage` implementations to forcefully return `void` from inside `setItem` and `removeItem`.
When using a library that returns the set value for `setItem` or `removeItem`, therefore returning a `string`, it causes Typescript to fail, requiring some weird workarounds.
For example, when using `localforage` (https://github.com/localForage/localForage) one needs to do what we describe below. Notice the `void` keyword.
```typescript
const storage: StateStorage = {
...localForage,
setItem: void localForage.setItem.bind(localForage)
}
```
Another, longer, alternative is
```typescript
const storage: StateStorage = {
...localForage,
// Curly braces are required because we need to "return `void`"
setItem: (name, value) => {
localStorage.setItem(name, value)
}
}
```
By changing the type implementation to ignore types - using unknown - we can simply use `localforage` - and similar libraries - as if we were using `window.localStorage`
* 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>
* Update connect-to-state-with-url-hash.md
Resolved a few errors and type errors in the persist and create state with URL example:
1. createJsonStorage not being called in storageOptions resulting in a type error.
2. Correct hook not being exported
3. Moved the creation of initial state inline to get the correct types passed from create/persist.
4. Used state type as generic for persist.
* yarn prettier run
* Update docs/guides/connect-to-state-with-url-hash.md
Better name for state in setter
Co-authored-by: Danilo Britto <dbritto.dev@gmail.com>
* prettier run
---------
Co-authored-by: Danilo Britto <dbritto.dev@gmail.com>
Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
* Update third-party-libraries.md
Adding zustand dev tool made by oslabs to the third party libraries.
* Update third-party-libraries.md
changed to alphabetical order
* Update third-party-libraries.md
formatted with prettier/which got rid of the extra space on line 17