import isEqual from 'lodash.isequal'; import { createReducer } from '@reduxjs/toolkit'; import { IContactsState,IContactsPayload} from '../../../typescript/redux/contacts/interfaces'; import { actionGetContactsSuccess, actionGetContactsReject } from '../action'; const initialState:IContactsState = { total: "0", limit: "0", page: "0", contacts: [] } const reducerContacts = createReducer(initialState, { [actionGetContactsSuccess.type]: (state, { payload }: IContactsPayload) => { if (isEqual(state, payload) === false) return payload return state; }, [actionGetContactsReject.type]: (state, _payload) => { return state; }, }); export default reducerContacts;