Skip to content

Commit

Permalink
fix(CatalogTileView): Fix to prevent category size updates after unmo…
Browse files Browse the repository at this point in the history
…unt (#910)
  • Loading branch information
jeff-phillips-18 authored and cdcabrera committed Nov 13, 2018
1 parent e975d8a commit df5ded3
Showing 1 changed file with 13 additions and 4 deletions.
Expand Up @@ -21,13 +21,26 @@ class CatalogTileViewCategory extends React.Component {
};
}

componentDidMount() {
this._isMounted = true;

// Watch for resizes and recompute the number shown when it does
this.computeNumShown();
this._resizeSensors.push(new ResizeSensor([this.categoryContainer], helpers.debounce(this.computeNumShown, 100)));
}

componentWillUnmount() {
this._isMounted = false;
this._resizeSensors.forEach(sensor => {
sensor.detach();
});
}

computeNumShown = () => {
if (!this._isMounted) {
return;
}

if (this.categoryContainer && layout) {
let rows = 1;

Expand All @@ -48,10 +61,6 @@ class CatalogTileViewCategory extends React.Component {
return;
}
this.categoryContainer = ref;
this.computeNumShown();

// Watch for resizes and recompute the number shown when it does
this._resizeSensors.push(new ResizeSensor([this.categoryContainer], helpers.debounce(this.computeNumShown, 100)));
};

render() {
Expand Down

0 comments on commit df5ded3

Please sign in to comment.