Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function configureStore(opts: ConfigureStoreOptions) {
const thunkMiddleware = thunk.withExtraArgument(opts.extra)
// Persist Middleware
const persistedReducer = persistReducer(persistConfig, rootReducer)
const router = routerMiddleware(history)
const enhancer = applyMiddleware(thunkMiddleware, ...appMiddleware, router)
const store = createStore(persistedReducer, opts.initialState || {}, enhancer)
const persistor = persistStore(store, undefined, opts.persistCallback)
return { store, persistor }
}
export default function configureStore(initialState, history) {
// Add so dispatched route actions to the history
const reduxRouterMiddleware = routerMiddleware(history);
const middleware = applyMiddleware(thunk, reduxRouterMiddleware);
return createStore(rootReducer, initialState, middleware);
}
componentDidMount() {
document.addEventListener('keydown', this.onKeyDown)
const { game, dispatch } = this.props
if (game.status === 'idle') {
dispatch(replace('/'))
}
// 这里不考虑这种情况:玩家在游戏过程中手动在地址栏中输入了 /gameover
}
componentWillMount() {
const { dispatch } = this.props;
const { query } = this.props.location;
// eslint-disable-next-line object-curly-newline, camelcase
const { refresh_token, access_token, expires_at, next = '/' } = query;
const tokens = {
refresh_token,
access_token,
expires_at: expires_at ? parseFloat(expires_at, 10) : Infinity, // eslint-disable-line camelcase
};
dispatch(storeTokens(tokens));
dispatch(getAuth(tokens));
dispatch(replace(next));
}
continueGuard(shouldShowConfirmationScreen, confirmAddKeyAlert, (dispatch) => {
// update the state to empty key in order to skip on leave hook
dispatch({ type: KEY_OPENED, payload: createBlankJPadKey() });
// navigate and set defaults
dispatch(push('/keys/_blank'));
dispatch(changeKeyValueType('string'));
const validation = { isValid: false, hint: '', isShowingHint: false };
setImmediate(() => dispatch(updateKeyPath(keyPath, validation)));
});
import 'babel-polyfill'
import React from 'react'
import { render } from 'react-dom'
import { browserHistory } from 'react-router'
import { syncHistoryWithStore } from 'react-router-redux'
import Root from './containers/Root'
import configureStore from './store/configureStore'
const store = configureStore()
const history = syncHistoryWithStore(browserHistory, store)
render(
,
document.getElementById('root')
)
import React from 'react'
import { render } from 'react-dom'
import { browserHistory } from 'react-router'
import { syncHistoryWithStore } from 'react-router-redux'
import Root from './containers/Root'
import configureStore from './store/configureStore'
const store = configureStore()
const history = syncHistoryWithStore(browserHistory, store)
render(
,
document.getElementById('root')
)
import React from 'react'
import { render } from 'react-dom'
import { browserHistory } from 'react-router'
import { syncHistoryWithStore } from 'react-router-redux'
import Root from './containers/Root'
import configureStore from './store/configureStore'
const store = configureStore()
const history = syncHistoryWithStore(browserHistory, store)
render(
,
document.getElementById('root')
)
import React from 'react'
import { render } from 'react-dom'
import { browserHistory } from 'react-router'
import { syncHistoryWithStore } from 'react-router-redux'
import Root from './containers/Root'
import configureStore from './store/configureStore'
const store = configureStore();
const history = syncHistoryWithStore(browserHistory, store);
render(
,
document.getElementById('root')
);