aohua / redux-state-sync

A lightweight middleware to sync your redux state across browser tabs
MIT License
233 stars 29 forks source link

Use with ConfigureStore() #154

Open seivad opened 2 years ago

seivad commented 2 years ago

Hey guys I cannot get this to work with configureStore() which is Redux's recommended way of working with fresh applications. Can someone provide an example of getting createStateSyncMiddleware() into the configureStore() middleware array?

If I enable it, my ID's and Entities are nulled out, but if I disable it, they are back to working again.

nayabshah commented 1 year ago

this works for me:

const config = { blacklist: ["persist/PERSIST", "persist/REHYDRATE"], };

const middlewares = [createStateSyncMiddleware(config), thunk];

export const store = configureStore({ reducer, middleware: middlewares, });

initStateWithPrevTab(store);

spd789562 commented 1 year ago

getDefaultMiddleware function and concat other middlewares is work for me

const extraMiddlewares = [createStateSyncMiddleware({  blacklist: 'some/Action'  })]
const store = configureStore({
    devTools: process.env.NODE_ENV !== 'production',
    reducer: rootReducer,
    middleware: (getDefaultMiddleware) =>
      getDefaultMiddleware({
        serializableCheck: {
          ignoredActions: [/* if you needed */],
        },
      }).concat(extraMiddlewares),
  })