export const getInitialStateFromLocalStorage = < T > ( storename , initialState ) : T => { let localState ; let parsedLocalState ; if ( typeof window !== 'undefined' ) { localState = localStorage . getItem ( storename ) ; try { if ( localState ) parsedLocalState = JSON . parse ( localState ) ; } catch ( err ) { console . error ( 'error parsing localstate' ) ; } } return { ... initialState , ... parsedLocalState } ; } ; export default getInitialStateFromLocalStorage ;