How to use the @reduxjs/toolkit.configureStore function in @reduxjs/toolkit

To help you get started, we’ve selected a few @reduxjs/toolkit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pipe-cd / pipe / pkg / app / web / src / store.ts View on Github external
import { configureStore, getDefaultMiddleware } from "@reduxjs/toolkit";
import { thunkErrorHandler } from "./middlewares/thunk-error-handler";
import { reducers } from "./modules";

export const store = configureStore({
  reducer: reducers,
  devTools: process.env.NODE_ENV === "development",
  middleware: [
    ...getDefaultMiddleware({}),
    thunkErrorHandler,
    // @see https://redux-toolkit.js.org/usage/usage-with-typescript#correct-typings-for-the-dispatch-type
  ] as const,
});

export type AppState = ReturnType;
export type AppDispatch = typeof store.dispatch;
github codeforpdx / recordexpungPDX / src / frontend / src / redux / store.tsx View on Github external
// See the following guides for an explanation:
// https://redux-starter-kit.js.org/usage/usage-guide
// https://redux.js.org/recipes/usage-with-typescript
import { configureStore, getDefaultMiddleware } from "@reduxjs/toolkit";
import { combineReducers } from "redux";

// Reducers:
import { searchReducer } from "./search/reducer";

const rootReducer = combineReducers({
  search: searchReducer,
});

const store = configureStore({
  reducer: rootReducer,
  middleware: [...getDefaultMiddleware()],
});

export type AppState = ReturnType;

export default store;
github pipe-cd / pipe / pkg / app / web / test-utils.tsx View on Github external
export const createReduxStore = (
  preloadedState?: Partial
): EnhancedStore => {
  return configureStore({
    reducer: reducers,
    middleware: [...middlewares, thunkErrorHandler],
    preloadedState,
  });
};
github pods-framework / pods / ui / js / dfv / src / admin / edit-pod / store / store.js View on Github external
export const initStore = ( props = {} ) => {
	const initialState = {
		...paths.UI.createTree( INITIAL_UI_STATE ),
		data: {
			fieldTypes: { ...props.config?.fieldTypes || {} },
			relatedObjects: { ...props.config?.relatedObjects || {} },
		},
		...omit( props?.config || {}, [ 'fieldTypes', 'relatedObjects' ] ),
	};

	const reduxStore = configureStore( {
		reducer,
		middleware: [ apiMiddleware ],
		preloadedState: initialState,
	} );

	const mappedSelectors = Object.keys( selectors ).reduce( ( acc, selectorKey ) => {
		acc[ selectorKey ] = ( ...args ) =>
			selectors[ selectorKey ]( reduxStore.getState(), ...args );
		return acc;
	}, {} );

	const mappedActions = Object.keys( actions ).reduce( ( acc, actionKey ) => {
		acc[ actionKey ] = ( ...args ) => reduxStore.dispatch( actions[ actionKey ]( ...args ) );
		return acc;
	}, {} );
github mregni / EmbyStat / EmbyStat.Web / ClientApp / src / store / index.tsx View on Github external
import { configureStore, Action } from '@reduxjs/toolkit';
import { ThunkAction } from 'redux-thunk';

import rootReducer, { RootState } from './RootReducer';

const store = configureStore({
  reducer: rootReducer,
});

if (process.env.NODE_ENV === 'development' && module.hot) {
  module.hot.accept('./RootReducer', () => {
    const newRootReducer = require('./RootReducer').default;
    store.replaceReducer(newRootReducer);
  });
}

export type AppDispatch = typeof store.dispatch;
export type AppThunk = ThunkAction>;

export default store;
github kinvolk / nebraska / frontend / src / js / stores / redux / store.ts View on Github external
import { configureStore } from '@reduxjs/toolkit';
import configReducer from './features/config';
import userReducer from './features/user';

const store = configureStore({
  reducer: {
    config: configReducer,
    user: userReducer,
  },
})

export type RootState = ReturnType
export type AppDispatch = typeof store.dispatch

export default store;
github berty / berty / js / packages / store / protocol / index.js View on Github external
export const init = () => {
	const sagaMiddleware = createSagaMiddleware()

	const store = configureStore({
		reducer: combineReducers(reducers),
		middleware: [sagaMiddleware],
	})

	sagaMiddleware.run(rootSaga)
	return store
}
github reduxjs / rtk-github-issues-example / src / app / store.ts View on Github external
import { configureStore, Action } from '@reduxjs/toolkit'
import { ThunkAction } from 'redux-thunk'

import rootReducer, { RootState } from './rootReducer'

const store = configureStore({
  reducer: rootReducer
})

if (process.env.NODE_ENV === 'development' && module.hot) {
  module.hot.accept('./rootReducer', () => {
    const newRootReducer = require('./rootReducer').default
    store.replaceReducer(newRootReducer)
  })
}

export type AppDispatch = typeof store.dispatch

export type AppThunk = ThunkAction>

export default store
github berty / berty / js / packages / store / settings / index.js View on Github external
export const init = () => {
	const sagaMiddleware = createSagaMiddleware()

	const store = configureStore({
		reducer: combineReducers(reducers),
		middleware: [sagaMiddleware],
	})

	sagaMiddleware.run(rootSaga)
	return store
}
github chaos-mesh / chaos-mesh / ui / src / store.ts View on Github external
const { createLogger } = require('redux-logger')

    const logger = createLogger({
      predicate: (_: any, action: AnyAction) => {
        if (action.type.includes('pending')) {
          return false
        }

        return true
      },
    })

    middlewares.push(logger)
  }

  const store = configureStore({
    reducer: rootReducer,
    middleware: middlewares,
    devTools: process.env.NODE_ENV !== 'production',
  })

  return store
}