Skip to content

Commit

Permalink
Data: Return default persisted by caught error
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Aug 1, 2018
1 parent c1071dd commit ba58f0a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/data/src/plugins/persistence/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ let _storageKey = 'WP_DATA';
export function getPersistedData() {
const { getStorage, getStorageKey } = plugin;
const persisted = getStorage().getItem( getStorageKey() );
return persisted ? JSON.parse( persisted ) : {};
try {
return JSON.parse( persisted );
} catch ( error ) {
return {};
}
}

/**
Expand Down

0 comments on commit ba58f0a

Please sign in to comment.