@reduxjs/toolkit#getDefaultMiddleware JavaScript Examples

The following examples show how to use @reduxjs/toolkit#getDefaultMiddleware. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: store.js    From cra-template-redux-auth-starter with MIT License 6 votes vote down vote up
export default function configureAppStore(preloadedState) {

  const sagaMiddleware = createSagaMiddleware();
  const store = configureStore({
    reducer: rootReducer,
    middleware: [...getDefaultMiddleware(), sagaMiddleware],
    preloadedState,
  })
  sagaMiddleware.run(rootSaga)

  if (process.env.NODE_ENV !== 'production' && module.hot) {
    module.hot.accept('app/rootReducers', () => store.replaceReducer(rootReducer))
  }
  return store
}
Example #2
Source File: index.js    From telar-cli with MIT License 6 votes vote down vote up
export default function configureAppStore(preloadedState) {
  const store = configureStore({
    reducer: rootReducer,
    middleware: [loggerMiddleware, ...getDefaultMiddleware()],
    preloadedState,
    enhancers: [monitorReducersEnhancer]
  })
  if (process.env.NODE_ENV !== 'production' && module.hot) {
    module.hot.accept('./reducers', () => store.replaceReducer(rootReducer))
  }
  return store
}
Example #3
Source File: index.js    From simplQ-frontend with GNU General Public License v3.0 6 votes vote down vote up
store = configureStore({
  reducer: rootReducer,
  middleware: getDefaultMiddleware({
    serializableCheck: {
      // Ignore auth in async thunks
      ignoredActionPaths: ['meta.arg.auth'],
    },
  }),
})
Example #4
Source File: configureStore.js    From Healthyhood with MIT License 6 votes vote down vote up
export default function () {
  return configureStore({
    reducer: rootReducer,
    middleware: [
      ...getDefaultMiddleware(), // returns THUNK and compose w/ DevTools
      logger,
      apiCall,
    ],
  });
}
Example #5
Source File: index.js    From sorbet-finance with GNU General Public License v3.0 6 votes vote down vote up
store = configureStore({
  reducer: {
    root,
    multicall,
    //application,
    // user,
    // transactions,
    // swap,
    // mint,
    // burn,
    // lists
  },
  middleware: [...getDefaultMiddleware(), save({ states: PERSISTED_KEYS })],
  preloadedState: load({ states: PERSISTED_KEYS }),
})
Example #6
Source File: index.js    From tclone with MIT License 6 votes vote down vote up
store = configureStore({
    reducer: {
        posts: postsReducer,
        search: searchReducer,
        trends: trendsReducer,
        users: usersReducer,
        notify: notifyReducer,
        auth: authReducer
    },
    middleware: [...getDefaultMiddleware({ immutableCheck: false })]
})
Example #7
Source File: index.js    From oasis-wallet-ext with Apache License 2.0 6 votes vote down vote up
applicationEntry = {
  async run() {
    this.createReduxStore();
    this.appInit(this.reduxStore)
    this.render();
  },

  async appInit(store) {
    appOpenListener(store)
    await getLocalStatus(store)
    getLocalNetConfig(store)
  },
  createReduxStore() {
    this.reduxStore = configureStore({
      reducer: rootReducer,
      middleware: [...getDefaultMiddleware(),
      ],
    });
  },
  render() {
    ReactDOM.render(
      <React.StrictMode>
        <Provider store={this.reduxStore}>
          <App />
        </Provider>
      </React.StrictMode>,
      document.getElementById("root")
    );
  },
}
Example #8
Source File: helpers.jsx    From frontend-app-library-authoring with GNU Affero General Public License v3.0 6 votes vote down vote up
ctxRender = async (ui, {
  options, context, storeOptions, history = createBrowserHistory(),
} = {}) => {
  const store = buildStore({ middleware: [...getDefaultMiddleware(), spyMiddleware], ...storeOptions });
  await initializeMockApp({ messages: [appMessages] });
  return render(
    <Provider store={store}>
      <Router history={history}>
        <AppContext.Provider value={context}>
          <IntlProvider locale="en">
            {ui}
          </IntlProvider>
        </AppContext.Provider>
      </Router>
    </Provider>,
    options,
  );
}
Example #9
Source File: configureStore.js    From apollo-epoch with MIT License 6 votes vote down vote up
export default function () {
  return configureStore({
    reducer: rootReducer,
    middleware: [
      ...getDefaultMiddleware(), // returns THUNK and compose w/ DevTools
      logger,
      initializePort,
    ],
  });
}
Example #10
Source File: index.js    From pine-interface with GNU General Public License v3.0 6 votes vote down vote up
store = configureStore({
  reducer: {
    root,
    multicall
    //application,
    // user,
    // transactions,
    // swap,
    // mint,
    // burn,
    // lists
  },
  middleware: [...getDefaultMiddleware(), save({ states: PERSISTED_KEYS })],
  preloadedState: load({ states: PERSISTED_KEYS })
})
Example #11
Source File: store.js    From secure-electron-template with MIT License 6 votes vote down vote up
store = configureStore({
  reducer: combineReducers({
    router: routerReducer,
    home: homeReducer,
    undoable: undoable(
      combineReducers({
        counter: counterReducer,
        complex: complexReducer
      })
    )
  }),
  middleware: [...getDefaultMiddleware({
    serializableCheck: false
  }), routerMiddleware]
})
Example #12
Source File: configureStore.js    From rtk-demo with MIT License 6 votes vote down vote up
export default function configureAppStore(initialState = {}) {
  const reduxSagaMonitorOptions = {};
  const sagaMiddleware = createSagaMiddleware(reduxSagaMonitorOptions);
  const { run: runSaga } = sagaMiddleware;

  // sagaMiddleware: Makes redux-sagas work
  const middlewares = [sagaMiddleware];

  const enhancers = [
    createInjectorsEnhancer({
      createReducer,
      runSaga,
    }),
  ];

  const store = configureStore({
    reducer: createReducer(),
    middleware: [...getDefaultMiddleware(), ...middlewares],
    preloadedState: initialState,
    devTools: process.env.NODE_ENV !== 'production',
    enhancers,
  });

  // Make reducers hot reloadable, see http://mxs.is/googmo
  /* istanbul ignore next */
  if (module.hot) {
    module.hot.accept('./reducers', () => {
      forceReducerReload(store);
    });
  }

  return store;
}
Example #13
Source File: store.js    From juggernaut-desktop with MIT License 5 votes vote down vote up
middleware = [...getDefaultMiddleware(), router, ipc]
Example #14
Source File: index.js    From auro-wallet-browser-extension with Apache License 2.0 5 votes vote down vote up
applicationEntry = {
  async run() {
    this.createReduxStore();
    await this.appInit(this.reduxStore)
    this.render();
  },

  async appInit(store) {
    extension.runtime.connect({ name: WALLET_CONNECT_TYPE.WALLET_APP_CONNECT });

    // init netRequest
    let netConfig =  await getLocalNetConfig(store)
    sendNetworkChangeMsg(netConfig.currentConfig)

    // init nextRoute
    let accountData = await getLocalStatus(store)
    const {nextRoute} = accountData
    // init Currency
    getLocalCurrencyConfig(store)
    
    if(nextRoute){
      store.dispatch(updateEntryWitchRoute(nextRoute))
    }
  },
  createReduxStore() {
    this.reduxStore = configureStore({
      reducer: rootReducer,
      middleware: [...getDefaultMiddleware(),
      ],
    });
  },
  render() {
    ReactDOM.render(
      <React.StrictMode>
        <Provider store={this.reduxStore}>
          <App />
        </Provider>
      </React.StrictMode>,
      document.getElementById("root")
    );
  },
}
Example #15
Source File: store.js    From social with The Unlicense 5 votes vote down vote up
customizedMiddleware = getDefaultMiddleware({
  immutableCheck: false,
  serializableCheck: false,
})
Example #16
Source File: index.jsx    From ResoBin with MIT License 5 votes vote down vote up
middleware = getDefaultMiddleware({
  serializableCheck: false,
})