Cancel debounced functions on unmount (https://github.com/woocommerce/woocommerce-blocks/pull/725)
This commit is contained in:
parent
10873b8503
commit
1cbef7dd39
|
@ -112,6 +112,10 @@ class FeaturedCategory extends Component {
|
||||||
this.getCategory();
|
this.getCategory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
this.debouncedGetCategory.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
componentDidUpdate( prevProps ) {
|
componentDidUpdate( prevProps ) {
|
||||||
if ( prevProps.attributes.categoryId !== this.props.attributes.categoryId ) {
|
if ( prevProps.attributes.categoryId !== this.props.attributes.categoryId ) {
|
||||||
this.debouncedGetCategory();
|
this.debouncedGetCategory();
|
||||||
|
|
|
@ -96,6 +96,10 @@ class FeaturedProduct extends Component {
|
||||||
this.getProduct();
|
this.getProduct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
this.debouncedGetProduct.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
componentDidUpdate( prevProps ) {
|
componentDidUpdate( prevProps ) {
|
||||||
if ( prevProps.attributes.productId !== this.props.attributes.productId ) {
|
if ( prevProps.attributes.productId !== this.props.attributes.productId ) {
|
||||||
this.debouncedGetProduct();
|
this.debouncedGetProduct();
|
||||||
|
|
|
@ -51,6 +51,10 @@ class ProductAttributeControl extends Component {
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
this.debouncedGetTerms.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
componentDidUpdate( prevProps, prevState ) {
|
componentDidUpdate( prevProps, prevState ) {
|
||||||
if ( prevState.attribute !== this.state.attribute ) {
|
if ( prevState.attribute !== this.state.attribute ) {
|
||||||
this.debouncedGetTerms();
|
this.debouncedGetTerms();
|
||||||
|
|
|
@ -35,6 +35,10 @@ class ProductsControl extends Component {
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
this.debouncedOnSearch.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
onSearch( search ) {
|
onSearch( search ) {
|
||||||
const { selected } = this.props;
|
const { selected } = this.props;
|
||||||
getProducts( { selected, search } )
|
getProducts( { selected, search } )
|
||||||
|
|
Loading…
Reference in New Issue