You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
633
+
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.
634
634
635
635
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
With the previous persist API, you would use `serialize`/`deserialize`
739
-
to deal with `Map` and `Set` and convert them into
740
-
an Array so they could be parsed into proper JSON.
738
+
In order to persist object types such as `Map` and `Set`, they will need to be converted to JSON-serializable types such as an `Array` which can be done by defining a custom `storage` engine.
741
739
742
-
The new persist API has deprecated `serialize`/`deserialize`.
743
-
744
-
Now, you will need to use the `storage` prop.
745
740
Let's say your state uses `Map` to handle a list of `transactions`,
746
-
then you can convert the Map into an Array in the storage prop:
741
+
then you can convert the `Map` into an `Array` in the `storage` prop which is shown below:
0 commit comments