Skip to content

Commit

Permalink
Discard changes to docs/integrations/persisting-store-data.md
Browse files Browse the repository at this point in the history
  • Loading branch information
charkour authored Dec 13, 2023
1 parent deace20 commit 04f6e03
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions docs/integrations/persisting-store-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ export const useBoundStore = create(
)
```

If you're using a type that `JSON.stringify()` doesn't support, you'll need to write your own serialization/deserialization code. However, if this is tedious, you can use third-party libraries to serialize and deserialize different types of data.
If you're using a type that JSON.stringify() doesn't support, you'll need to write your own serialization/deserialization code. However, if this is tedious, you can use third-party libraries to serialize and deserialize different types of data.

For example, [Superjson](https://github.com/blitz-js/superjson) can serialize data along with its type, allowing the data to be parsed back to its original type upon deserialization

Expand Down Expand Up @@ -735,8 +735,15 @@ export const useBearStore = create<MyState>()(

### How do I use it with Map and Set

If your state uses `Map` or `Set` to handle a list of `transactions`,
then you can convert the `Map` into an Array in the `storage` prop:
With the previous persist API, you would use `serialize`/`deserialize`
to deal with `Map` and `Set` and convert them into
an Array so they could be parsed into proper JSON.

The new persist API has deprecated `serialize`/`deserialize`.

Now, you will need to use the `storage` prop.
Let's say your state uses `Map` to handle a list of `transactions`,
then you can convert the Map into an Array in the storage prop:

```ts

Expand Down

0 comments on commit 04f6e03

Please sign in to comment.