redux#createStore JavaScript Examples
The following examples show how to use
redux#createStore.
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: test-utils.js From social-media-strategy-fe with MIT License | 7 votes |
function render(
ui,
{
initialState,
store = createStore(reducer, initialState),
...renderOptions
} = {}
) {
function Wrapper({children}) {
return <Provider store={store}>{children}</Provider>;
}
return rtlRender(ui, { wrapper: Wrapper, ...renderOptions });
}
Example #2
Source File: configureStore.dev.js From ashteki with GNU Affero General Public License v3.0 | 6 votes |
export default function configureStore(initialState) {
const store = createStore(rootReducer, initialState, enhancer);
if (module.hot) {
module.hot.accept('./redux/reducers', () =>
store.replaceReducer(require('./redux/reducers').default)
);
}
return store;
}
Example #3
Source File: index.js From fhir-app-starter with MIT License | 6 votes |
export default function configureStore(initialState = {}, history) {
let composeEnhancers = compose;
const reduxSagaMonitorOptions = {};
// If Redux Dev Tools and Saga Dev Tools Extensions are installed, enable them
/* istanbul ignore next */
if (process.env.NODE_ENV !== 'production' && typeof window === 'object') {
/* eslint-disable no-underscore-dangle */
if (window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__)
composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({});
// NOTE: Uncomment the code below to restore support for Redux Saga
// Dev Tools once it supports redux-saga version 1.x.x
// if (window.__SAGA_MONITOR_EXTENSION__)
// reduxSagaMonitorOptions = {
// sagaMonitor: window.__SAGA_MONITOR_EXTENSION__,
// };
/* eslint-enable */
}
const sagaMiddleware = createSagaMiddleware(reduxSagaMonitorOptions);
// Create the store with two middlewares
// 1. sagaMiddleware: Makes redux-sagas work
// 2. routerMiddleware: Syncs the location/URL path to the state
const middlewares = [sagaMiddleware, routerMiddleware(history), logger];
const enhancers = [applyMiddleware(...middlewares)];
const store = createStore(rootReducer, initialState, composeEnhancers(...enhancers));
// Extensions
store.runSaga = sagaMiddleware.run;
store.runSaga(sagas);
return store;
}
Example #4
Source File: store.js From allay-fe with MIT License | 6 votes |
store = createStore(
rootReducer,
composeEnhancers(
applyMiddleware(
thunk
//, logger
)
)
)
Example #5
Source File: Login.spec.js From carpal-fe with MIT License | 6 votes |
function renderWithRedux(
ui,
{ store = createStore(reducer, applyMiddleware(thunk)) } = {}
) {
return {
...render(<Provider store={store}>{<Router>{ui}</Router>}</Provider>),
store
};
}
Example #6
Source File: ApplicantContactInfo.test.js From grants-fe with MIT License | 6 votes |
function render(
ui,
{
initialState = initialReducerState,
store = createStore(reducer, initialState),
...renderOptions
} = {}
) {
function Wrapper({ children }) {
return <Provider store={store}>{children}</Provider>;
}
return rtlRender(ui, { wrapper: Wrapper, ...renderOptions });
}
Example #7
Source File: Activity.test.js From quake-fe with MIT License | 6 votes |
describe("Activity.js Tests", () => {
const store = createStore(reducers, applyMiddleware(thunk));
it("should render...", () => {
rtl.render(
<Provider store={store}>
<Activity />
</Provider>
);
});
});
Example #8
Source File: store.js From resumeker-fe with MIT License | 6 votes |
export default function store(preloadedState) {
const store = createStore(
rootReducer(history),
preloadedState,
applyMiddleware(routerMiddleware(history), thunk, logger)
);
return store;
}
Example #9
Source File: store.js From react-firebase-admin with MIT License | 6 votes |
configureStore = initialState => {
const middlewares = [];
const composeEnhancers =
(process.env.NODE_ENV === 'development'
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
: null) || compose;
middlewares.push(applyMiddleware(thunk));
const store = createStore(
rootReducer,
initialState,
composeEnhancers(...middlewares)
);
store.dispatch(verifyAuth());
const persistor = persistStore(store);
return { store, persistor };
}
Example #10
Source File: store.js From Designer-Client with GNU General Public License v3.0 | 6 votes |
store = () => {
let store = createStore(
persistedReducer,
composeWithDevTools(
applyMiddleware(
axiosMiddleware(axiosClient),
thunkMiddleware,
loggerMiddleware
),
),
);
let persistor = persistStore(store);
return { store, persistor }
}
Example #11
Source File: index.js From defizap-frontend with GNU General Public License v2.0 | 6 votes |
configureStore = (initialState, history) => {
const middlewares = [thunk, routerMiddleware(history)];
const storeEnhancers = [];
const isDev = process.env.NODE_ENV !== 'production';
if (isDev) {
// allow devs to use their own plugged in browser redux dev tool instead of the builtin component
const devTools = DevTools();
const devToolsEnhancer = window.__REDUX_DEVTOOLS_EXTENSION__
? window.__REDUX_DEVTOOLS_EXTENSION__()
: devTools.instrument();
storeEnhancers.push(devToolsEnhancer);
}
const middlewareEnhancer = applyMiddleware(...middlewares);
storeEnhancers.unshift(middlewareEnhancer);
const store = createStore(
rootReducer(history),
initialState,
compose(...storeEnhancers)
);
if (isDev && module.hot && module.hot.accept) {
module.hot.accept('../reducers', () => {
const nextRootReducer = lazy(() => import('../reducers'));
store.replaceReducer(nextRootReducer);
});
}
return store;
}
Example #12
Source File: index.js From Spoke with MIT License | 6 votes |
constructor(history, initialState = {}) {
const reducer = combineReducers({
...reducers,
apollo: ApolloClientSingleton.reducer(),
routing: routerReducer
});
this.data = createStore(
reducer,
initialState,
compose(
applyMiddleware(
routerMiddleware(history),
ApolloClientSingleton.middleware(),
ReduxThunk.withExtraArgument(ApolloClientSingleton)
),
typeof window === "object" &&
typeof window.devToolsExtension !== "undefined"
? window.devToolsExtension()
: f => f
)
);
}
Example #13
Source File: store.js From OSC-Legal with MIT License | 6 votes |
export default function configureStore(initialState) {
// const epicMiddleware = createEpicMiddleware(rootEpic);
const bundle = compose(applyMiddleware(thunkMiddleware));
const createStoreWithMiddleware = bundle(createStore);
const store = createStoreWithMiddleware(
reducers,
initialState,
window.devToolsExtension ? window.devToolsExtension() : f => f
);
return store;
}
Example #14
Source File: configureStore.js From HexactaLabs-NetCore_React-Initial with Apache License 2.0 | 6 votes |
export default function configureStore(history, initialState) {
const reducers = {
form: formReducer,
router: connectRouter(history),
auth,
home,
provider,
store
};
const middleware = [thunk, routerMiddleware(history)];
const enhancers = [];
// eslint-disable-next-line no-undef
const isDevelopment = process.env.NODE_ENV === "development";
if (
isDevelopment &&
typeof window !== "undefined" &&
window.devToolsExtension
) {
enhancers.push(window.devToolsExtension());
}
const rootReducer = combineReducers(reducers);
return createStore(
rootReducer,
initialState,
compose(
applyMiddleware(...middleware),
...enhancers
)
);
}
Example #15
Source File: configureStore.js From flame-coach-web with MIT License | 6 votes |
createOwnStore = (reducers) => {
const middlewares = [thunkMiddleware, logger];
const middlewareEnchancer = applyMiddleware(...middlewares);
const enchancers = [middlewareEnchancer];
const composedEnchancers = composeWithDevTools(...enchancers);
return createStore(reducers, undefined, composedEnchancers);
}
Example #16
Source File: index.js From covid with GNU General Public License v3.0 | 6 votes |
store = createStore(
rootReducer,
// (
// typeof window === 'object'
// && window.__REDUX_DEVTOOLS_EXTENSION__
// && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
// ) && window.__REDUX_DEVTOOLS_EXTENSION__({
// stateSanitizer: (state) => state.storedGeojson ? { ...state, storedData: '<<EXCLUDED>>', storedGeojson: '<<EXCLUDED>>' } : state
// })
)
Example #17
Source File: createStore.js From volt-mx-tutorials with Apache License 2.0 | 6 votes |
initStore = (initialState = {}) => {
let middlewares = createMiddlewares();
return createStore(
rootReducer,
initialState,
composeEnhancers(applyMiddleware(...middlewares))
);
}
Example #18
Source File: store.js From IBM-db2-blockchain-insurance-application with Apache License 2.0 | 6 votes |
export default function configStore(initialState) {
return createStore(
rootReducer,
initialState,
applyMiddleware(
ReduxThunk
)
);
}
Example #19
Source File: configureStore.js From dexwebapp with Apache License 2.0 | 6 votes |
// Setting preloadedState is still behind setting initState in each reducer
export default function configureStore(preloadedState) {
const composeEnhancer =
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
createRootReducer(history),
preloadedState,
composeEnhancer(
applyMiddleware(
thunk,
routerMiddleware(history),
trackingMiddleware(tracker)
)
)
);
// Hot reloading
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('./reducers', () => {
store.replaceReducer(createRootReducer(history));
});
}
return store;
}
Example #20
Source File: configureStore.js From HexactaLabs-NetCore_React-Level2 with Apache License 2.0 | 6 votes |
export default function configureStore(history, initialState) {
const reducers = {
form: formReducer,
router: connectRouter(history),
auth,
home,
provider,
productType,
store
};
const middleware = [thunk, routerMiddleware(history)];
const enhancers = [];
// eslint-disable-next-line no-undef
const isDevelopment = process.env.NODE_ENV === "development";
if (
isDevelopment &&
typeof window !== "undefined" &&
window.devToolsExtension
) {
enhancers.push(window.devToolsExtension());
}
const rootReducer = combineReducers(reducers);
return createStore(
rootReducer,
initialState,
compose(
applyMiddleware(...middleware),
...enhancers
)
);
}
Example #21
Source File: index.js From WebApp with MIT License | 6 votes |
ReactDOM.render(
<Provider store={createStore(reducers, applyMiddleware(thunk, logger))}>
<MuiThemeProvider theme={Theme}>
<IntlProvider locale="en" messages={messagesEn}>
<App/>
</IntlProvider>
</MuiThemeProvider>
</Provider>,
document.querySelector('#root')
)
Example #22
Source File: store.js From archeage-tools with The Unlicense | 6 votes |
configureStore = (history) => {
const store = createStore(
rootReducer(history),
enhancer(history),
);
/* eslint-disable no-undef */
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('reducers', () => {
store.replaceReducer(rootReducer(history));
});
}
return store;
}
Example #23
Source File: store.js From NextcloudDuplicateFinder with GNU Affero General Public License v3.0 | 6 votes |
store = createStore(
persistedReducer,
undefined,
composeWithDevTools(
applyMiddleware(
sagaMiddleware
)
)
)
Example #24
Source File: configureStore.js From doraemon with GNU General Public License v3.0 | 6 votes |
export default function configure(initialState) {
// console.log('initialState', initialState)
const create = window.devToolsExtension
? window.devToolsExtension()(createStore)
: createStore
const createStoreWithMiddleware = applyMiddleware(
reduxRouterMiddleware,
thunkMiddleware,
logger,
// router,
)(create)
const store = createStoreWithMiddleware(rootReducer, initialState)
if (module.hot) {
module.hot.accept('../reducers', () => {
store.replaceReducer(nextReducer)
})
}
return store
}
Example #25
Source File: configureStore.js From sampo-ui with MIT License | 6 votes |
export default function configureStore (preloadedState) {
const epicMiddleware = createEpicMiddleware()
const middlewares = [epicMiddleware]
// https://github.com/zalmoxisus/redux-devtools-extension#11-basic-store
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
const composedEnhancers = composeEnhancers(
applyMiddleware(...middlewares)
// other store enhancers could be added here
)
const store = createStore(reducer, preloadedState, composedEnhancers)
epicMiddleware.run(rootEpic)
bindActionCreators(toastrActions, store.dispatch)
return store
}
Example #26
Source File: store.js From tomato-food-delivery with Apache License 2.0 | 6 votes |
store = createStore(
rootReducer,
initialState,
compose(
applyMiddleware(...middleware),
(window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__()) ||
compose
)
)
Example #27
Source File: index.js From scalable-form-platform with MIT License | 6 votes |
constructor(...args) {
super(...args);
this.state = {};
this.namespace = util.getRandomString(8);
this.store = createStore(
combineReducers(xformBuilderReducer),
compose(applyMiddleware(thunkMiddleware))
);
}
Example #28
Source File: store.js From CITZ-IMB-Capstone2020 with Apache License 2.0 | 6 votes |
//used Redux store to dispatch an action
//3 return values will used in index.js to monitor the status of serviseworker
function configureStore() {
return createStore(rootReducer, {
serviceWorkerInitialized: false,
serviceWorkerUpdated: false,
serviceWorkerRegistration: null,
});
}
Example #29
Source File: configureStore.dev.js From Lambda with MIT License | 6 votes |
export default function configureStore(history) {
const composeEnhancers =
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const enhancer = composeEnhancers(
applyMiddleware(thunk, routerMiddleware(history))
);
const store = createStore(root, enhancer);
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept("./rootReducer", () => {
const nextRootReducer = require("./rootReducer").default;
store.replaceReducer(nextRootReducer);
});
}
return store;
}