Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
Fix initial data prop not set in storage.
Browse files Browse the repository at this point in the history
  • Loading branch information
T4rk1n committed Sep 21, 2018
1 parent f8e8495 commit 3a1111e
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/components/Storage.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,18 @@ export default class Storage extends React.Component {
window.addEventListener('storage', this.onStorageChange);
}

if (setProps) {
// Take the data from storage, ignore the prop data on load.
const old = this._backstore.getItem(id);
if (dataCheck(old, data)) {
setProps({
data: old,
modified_timestamp: this._backstore.getModified(id)
});
}
const old = this._backstore.getItem(id);
if (R.isNil(old) && data) {
// Initial data mount
this._backstore.setItem(id, data);
return;
}

if (setProps && dataCheck(old, data)) {
setProps({
data: old,
modified_timestamp: this._backstore.getModified(id)
});
}
}

Expand Down

0 comments on commit 3a1111e

Please sign in to comment.