mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-19 21:16:18 +00:00
Migrated redux store creation to redux toolkit
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
import ReduxThunk from 'redux-thunk';
|
||||
import { applyMiddleware, compose, createStore } from 'redux';
|
||||
import { save, load, RLSOptions } from 'redux-localstorage-simple';
|
||||
import reducers from '../reducers';
|
||||
import { configureStore } from '@reduxjs/toolkit';
|
||||
import reducer from '../reducers';
|
||||
import { migrateDeprecatedSettings } from '../settings/helpers';
|
||||
import { ShlinkState } from './types';
|
||||
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
// eslint-disable-next-line no-mixed-operators
|
||||
const composeEnhancers: Function = !isProduction && (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
|
||||
|
||||
const localStorageConfig: RLSOptions = {
|
||||
states: ['settings', 'servers'],
|
||||
namespace: 'shlink',
|
||||
@@ -17,6 +13,11 @@ const localStorageConfig: RLSOptions = {
|
||||
};
|
||||
const preloadedState = migrateDeprecatedSettings(load(localStorageConfig) as ShlinkState);
|
||||
|
||||
export const store = createStore(reducers, preloadedState, composeEnhancers(
|
||||
applyMiddleware(save(localStorageConfig), ReduxThunk),
|
||||
));
|
||||
export const store = configureStore({
|
||||
devTools: !isProduction,
|
||||
reducer,
|
||||
preloadedState,
|
||||
middleware: (defaultMiddlewaresIncludingReduxThunk) => defaultMiddlewaresIncludingReduxThunk(
|
||||
{ immutableCheck: false, serializableCheck: false }, // State is too big for these
|
||||
).concat(save(localStorageConfig)),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user