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();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.debouncedGetCategory.cancel();
|
||||
}
|
||||
|
||||
componentDidUpdate( prevProps ) {
|
||||
if ( prevProps.attributes.categoryId !== this.props.attributes.categoryId ) {
|
||||
this.debouncedGetCategory();
|
||||
|
|
|
@ -96,6 +96,10 @@ class FeaturedProduct extends Component {
|
|||
this.getProduct();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.debouncedGetProduct.cancel();
|
||||
}
|
||||
|
||||
componentDidUpdate( prevProps ) {
|
||||
if ( prevProps.attributes.productId !== this.props.attributes.productId ) {
|
||||
this.debouncedGetProduct();
|
||||
|
|
|
@ -51,6 +51,10 @@ class ProductAttributeControl extends Component {
|
|||
} );
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.debouncedGetTerms.cancel();
|
||||
}
|
||||
|
||||
componentDidUpdate( prevProps, prevState ) {
|
||||
if ( prevState.attribute !== this.state.attribute ) {
|
||||
this.debouncedGetTerms();
|
||||
|
|
|
@ -35,6 +35,10 @@ class ProductsControl extends Component {
|
|||
} );
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.debouncedOnSearch.cancel();
|
||||
}
|
||||
|
||||
onSearch( search ) {
|
||||
const { selected } = this.props;
|
||||
getProducts( { selected, search } )
|
||||
|
|
Loading…
Reference in New Issue