I'm keeping some objects in my Redux store, and some properties are of the type: Firestore.Timestamp.

Example:

blogPost: {
  title: string,
  createdAt: firestore.Timestamp
}

And I'm getting these warnings:

A non-serializable value was detected in the state, in the path: BLOGPOST.blogPost.createdAt. Value: t {seconds: 1583488258, nanoseconds: 805000000}

Take a look at the reducer(s) handling this action type: BLOGPOST/LOAD_BLOGPOST_SUCCESS. (See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)

From: https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state

It is highly recommended that you only put plain serializable objects, arrays, and primitives into your store. It's technically possible to insert non-serializable items into the store, but doing so can break the ability to persist and rehydrate the contents of a store, as well as interfere with time-travel debugging.

If you are okay with things like persistence and time-travel debugging potentially not working as intended, then you are totally welcome to put non-serializable items into your Redux store. Ultimately, it's your application, and how you implement it is up to you. As with many other things about Redux, just be sure you understand what tradeoffs are involved.

I definitely want persistence and time-travel to keep working well. Should I bother to convert my firestore.Timestamp to JS Dates before dispatching it to Redux ? Or can I safely ignore this?

1

There are 1 answers

4
markerikson On

Per that description, we would specifically recommend that you convert those to a primitive value such as a timestamp string or a number.