Import individual lodash functions

This commit is contained in:
Nathan Bierema 2022-01-19 11:47:50 -05:00
parent 5d6c81aefc
commit 3ed8c11b75

View File

@ -1,4 +1,5 @@
import _ from 'lodash'; import mapValues from 'lodash/mapValues';
import identity from 'lodash/identity';
import { Action, PreloadedState, Reducer, StoreEnhancer } from 'redux'; import { Action, PreloadedState, Reducer, StoreEnhancer } from 'redux';
import { LiftedState } from '@redux-devtools/instrument'; import { LiftedState } from '@redux-devtools/instrument';
@ -8,8 +9,8 @@ export default function persistState<
MonitorState MonitorState
>( >(
sessionId?: string | null, sessionId?: string | null,
deserializeState: (state: S) => S = _.identity, deserializeState: (state: S) => S = identity,
deserializeAction: (action: A) => A = _.identity deserializeAction: (action: A) => A = identity
): StoreEnhancer { ): StoreEnhancer {
if (!sessionId) { if (!sessionId) {
return (next) => return (next) =>
@ -22,7 +23,7 @@ export default function persistState<
): LiftedState<S, A, MonitorState> { ): LiftedState<S, A, MonitorState> {
return { return {
...state, ...state,
actionsById: _.mapValues(state.actionsById, (liftedAction) => ({ actionsById: mapValues(state.actionsById, (liftedAction) => ({
...liftedAction, ...liftedAction,
action: deserializeAction(liftedAction.action), action: deserializeAction(liftedAction.action),
})), })),