@@ -90,14 +90,13 @@ export const persistMiddleware = (save: SaveCallback, load: LoadCallback) => (ne
9090 * @param debug - Debug data to the console
9191 *
9292 */
93- export function createPersistMachine ( structure : any , store : any , debug : boolean ) {
93+ export function createPersistMachine ( structure : any , store : any , debug : boolean ) {
9494 /*
9595 * We do an initial map of the structure
9696 */
9797 _map ( structure , ( object : any , name : any ) => {
9898 // Catch any errors with the persist configuration
99- if ( _isNil ( object . values ) ) throw new Error ( "You need to define a `values` array in your persist object." ) ;
100- if ( _isNil ( object . key ) ) throw new Error ( "You need to define a `key` value to identify your data in your persist object." ) ;
99+ if ( _isNil ( object . key ) ) throw new Error ( "You need to define a `key` value to identify your data in your persist object." ) ;
101100
102101 // Get the static key for mapping
103102 const {
@@ -146,7 +145,13 @@ export function createPersistMachine(structure: any, store: any, debug: boolean)
146145 * Builds a state only containing the values
147146 * we care about, which are defined in structure.
148147 */
149- const newState = _pickBy ( state , ( value : any , key : any ) => {
148+ const newState = _pickBy ( state , ( value : any , key : any ) => {
149+ /**
150+ * If nothing is passed to the `values`
151+ * parameter, all values will be used.
152+ */
153+ if ( _isNil ( stateValues ) ) return value ;
154+
150155 if ( stateValues . includes ( key ) ) return value ;
151156 } ) ;
152157
0 commit comments