export const saveToStorage = ( name , state ) => { try { const serializedState = JSON . stringify ( state ) ; localStorage . setItem ( name , serializedState ) ; } catch ( error ) { console . error ( error ) ; } } ; export const getFromStorage = ( name ) => { try { const serializedState = localStorage . getItem ( name ) ; if ( serializedState === null ) { return undefined ; } return JSON . parse ( serializedState ) ; } catch ( error ) { console . error ( error ) ; return undefined ; } } ;