Skip to content

Commit

Permalink
Improving resource renderer for better caching.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Krulis committed Jan 23, 2018
1 parent 3306f64 commit afce002
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/helpers/ResourceRenderer/ResourceRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,18 @@ class ResourceRenderer extends Component {
this.oldResources === null ||
!shallowResourcesEqual(this.oldResources, resources)
) {
this.oldResources = resources;
this.oldData = resources
.filter(res => !isDeleting(res))
.filter(res => !isDeleted(res))
.filter(res => !isPosting(res))
.map(getJsData);
.map(
(res, idx) =>
// If a particular resource did not change, re-use its old data
this.oldResources && this.oldResources[idx] === res
? this.oldData[idx]
: getJsData(res)
);
this.oldResources = resources;
}
return returnAsArray ? ready(this.oldData) : ready(...this.oldData);
};
Expand All @@ -89,7 +95,6 @@ class ResourceRenderer extends Component {
noIcons = false,
loading = defaultLoading(noIcons),
failed = defaultFailed(noIcons),
// children: ready,
resource,
hiddenUntilReady = false,
forceLoading = false
Expand Down

0 comments on commit afce002

Please sign in to comment.