insomnia/packages/insomnia-app/app/ui/redux/create.ts
Jack Kavanagh 28378dc3fd
spike: use babel preset typescript to transpile app (#4142)
* use babel-preset-typescript

* run type-check in release process
2021-11-03 08:06:52 +00:00

29 lines
933 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/// <reference types="webpack-env" />
import { applyMiddleware, compose, createStore, Store } from 'redux';
import thunkMiddleware from 'redux-thunk';
import { reducer } from './modules';
// TODO there's a circular dependency between this file and /redux/create
export default function() {
const composeEnhancers =
typeof window === 'object' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
// Specify extensions options like name, actionsBlacklist, actionsCreators, serialize...
})
: compose;
const middleware = [thunkMiddleware];
const enhancer = composeEnhancers(
applyMiddleware(...middleware), // other store enhancers if any
);
const store = createStore(reducer, enhancer);
if (__DEV__ && module.hot) {
module.hot.accept('./modules/index', () => {
store.replaceReducer(reducer);
});
}
return store as Store;
}