In redux state tree How do we store dates ?
ie,
state={
fromTime: action.payload.fromTimeMoment,
dateTime: action.payload.dateTimeEs6,
toTime: action.payload.toTimeAsString,
}
In our current project we have stored it as moment objects, still not sure if that was the right thing to do.
When dealing with dates I'd prefer to store as a unix format or ISO string. The reason for this is because I might want to save the state to the local storage for speed things up for second time users.
Keeping instances of other classes (or in this case moment) in the store, you might find some problems while serializing the state.
Using reselect you can create a moment instance to access the date value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With