Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const createStoreWithMiddleware = () => {
const middleware = applyMiddleware(apiMiddleware)
if (__DEV__) {
const logSlowReducers = require('app/utils/devLogSlowReducers')
const reducer = combineReducers(logSlowReducers(reducers))
const { devTools, persistState } = require('redux-devtools')
const finalCreateStore = compose(
middleware,
devTools(),
persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
)(createStore)
const store = finalCreateStore(reducer)
if (module.hot) { // Enable Webpack hot module replacement for reducers
module.hot.accept('app/reducers', () => {
const nextRootReducer = combineReducers(
logSlowReducers(require('app/reducers/index'))
)
store.replaceReducer(nextRootReducer)
})
}
return store
} else {
import {createStore, applyMiddleware, combineReducers, compose} from 'redux';
import thunkMiddleware from 'redux-thunk';
import {devTools, persistState} from 'redux-devtools';
import * as reducers from '../reducers/index';
let createStoreWithMiddleware;
// Configure the dev tools when in DEV mode
if (__DEV__) {
createStoreWithMiddleware = compose(
applyMiddleware(thunkMiddleware),
devTools(),
persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
)(createStore);
} else {
createStoreWithMiddleware = applyMiddleware(thunkMiddleware)(createStore);
}
const rootReducer = combineReducers(reducers);
export default function configureStore(initialState) {
return createStoreWithMiddleware(rootReducer, initialState);
}
import createLogger from 'redux-logger';
import { compose, createStore, applyMiddleware } from 'redux';
import { Provider } from 'react-redux';
import { devTools, persistState } from 'redux-devtools';
import { DevTools, DebugPanel, LogMonitor } from 'redux-devtools/lib/react';
import App from './containers/App';
import todoApp from './reducers';
const loggerMiddleware = createLogger();
const createStoreWithMiddleware = compose(
applyMiddleware(
thunkMiddleware, // lets us dispatch() functions
loggerMiddleware // neat middleware that logs actions
),
devTools()
)(createStore);
const store = createStoreWithMiddleware(todoApp);
render(
<div>
</div>,
document.getElementById('root')
);
import React from 'react';
import {Provider} from 'react-redux';
import Root from './root';
import { compose, createStore, applyMiddleware } from 'redux';
import { devTools, persistState } from 'redux-devtools';
import { DevTools, DebugPanel, LogMonitor } from 'redux-devtools/lib/react';
import { serverMiddleware} from './server'
import '../../../styles.css'
import _ from 'lodash'
import reducer from './reducer'
const finalCreateStore = compose(
applyMiddleware(serverMiddleware),
devTools(),
persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
)(createStore);
const store = finalCreateStore(reducer);
React.render(
<div>
{() => }
</div>,
document.getElementById('app')
);
export default function(client, data) {
const middleware = createMiddleware(client);
let __createStore;
if (__DEV__ && __CLIENT__ && __DEVTOOLS__) {
const { devTools, persistState } = require('redux-devtools');
__createStore = compose(
applyMiddleware(middleware),
devTools(),
persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/)),
createStore
);
} else {
__createStore = applyMiddleware(middleware)(createStore);
}
return __createStore(reducer, data);
}
children: PropTypes.object,
};
const routes = (
}
}
);
const store = compose(
reduxReactRouter({
routes,
createHistory,
}),
devTools()
)(createStore)(reducer);
class Root extends Component {
constructor() {
super();
this.state = {
showDebug: false,
};
}
render() {
const {showDebug} = this.state;
const debug = [];
const debugButton = [];
if (__DEVTOOLS__) {
debugButton.push(
import { createStore, applyMiddleware, compose } from "redux";
import { devTools, persistState } from 'redux-devtools';
import RootReducer from "../reducers/RootReducer";
import thunk from "redux-thunk";
import createLogger from "redux-logger";
import { createHistory } from "history";
import { routerStateReducer, reduxReactRouter } from "redux-router";
const logger = createLogger();
const createAppStore = compose(
applyMiddleware(thunk, logger),
devTools(),
persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/)),
reduxReactRouter({createHistory})
)(createStore);
export default function configStore() {
return createAppStore(RootReducer);
}
function createReduxStore() {
const finalCreateStore = compose(devTools())(createStore);
return finalCreateStore(() => {});
}
function message(state = 'Hello world!', action) {
switch (action.type) {
case SET_MESSAGE:
return action.message;
default:
return state;
}
}
export const appState = combineReducers({
message
});
export const finalCreateStore = compose(
devTools()
)(createStore);
import { applyMiddleware, createStore, combineReducers, compose } from 'redux';
import { devTools, persistState } from 'redux-devtools';
import rootReducer from './reducers/index';
import thunk from 'redux-thunk';
const middlewares = applyMiddleware(thunk);
let finalCreateStore;
if (process.env.DEVTOOLS) {
finalCreateStore = compose(
middlewares,
devTools(),
persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/)),
)(createStore);
} else {
finalCreateStore = compose(
middlewares
)(createStore);
}
export default function(initialState) {
const store = finalCreateStore(rootReducer, initialState);
if (module.hot) {
module.hot.accept('./reducers', () => {
const nextRootReducer = require('./reducers/index');
store.replaceReducer(nextRootReducer);
});