zooniverse / Panoptes-Front-End

Front end for zooniverse/Panoptes
https://www.zooniverse.org
Apache License 2.0
64 stars 76 forks source link

Migrate the Redux store to `configureStore` #6132

Open eatyourgreens opened 2 years ago

eatyourgreens commented 2 years ago

Replace createStore with configureStore.

See the discussion in https://github.com/reduxjs/redux/issues/4325

Nice to have, but not high priority.

eatyourgreens commented 2 years ago

configureStore includes middleware that warns if you pass an action payload that isn't serialisable: https://redux-toolkit.js.org/api/serializabilityMiddleware

That's very good practice but the Resource objects returned by the API client aren't serialisable, so this will break the store wherever a resource is fetched by the API client then dispatched directly in an action, without first destructuring it to a static snapshot. The reasoning behind this is that store state cannot be mutated outside the store, but API client Resource objects are mutable objects by design eg. resource.update(changes).

eatyourgreens commented 2 years ago

See https://github.com/zooniverse/pandora/pull/253 for the changes to reducers and action creators that were required to get this working in the translations editor.