diff --git a/plugins/woocommerce-admin/client/customer-effort-score-tracks/customer-effort-score-tracks-container.js b/plugins/woocommerce-admin/client/customer-effort-score-tracks/customer-effort-score-tracks-container.js index 4b55614aa21..017748e52fa 100644 --- a/plugins/woocommerce-admin/client/customer-effort-score-tracks/customer-effort-score-tracks-container.js +++ b/plugins/woocommerce-admin/client/customer-effort-score-tracks/customer-effort-score-tracks-container.js @@ -1,6 +1,7 @@ /** * External dependencies */ +import { useEffect } from 'react'; import { compose } from '@wordpress/compose'; import { withDispatch, withSelect } from '@wordpress/data'; import { OPTIONS_STORE_NAME } from '@woocommerce/data'; @@ -29,18 +30,19 @@ function CustomerEffortScoreTracksContainer( { resolving, clearQueue, } ) { - if ( resolving ) { - return null; - } - const queueForPage = queue.filter( ( item ) => item.pagenow === window.pagenow && item.adminpage === window.adminpage ); + useEffect( () => { + if ( queueForPage.length ) { + clearQueue(); + } + }, [ queueForPage ] ); - if ( queueForPage.length ) { - clearQueue(); + if ( resolving ) { + return null; } return ( diff --git a/plugins/woocommerce/changelog/fix-setstate-diff-component2 b/plugins/woocommerce/changelog/fix-setstate-diff-component2 new file mode 100644 index 00000000000..2d3f3287b2d --- /dev/null +++ b/plugins/woocommerce/changelog/fix-setstate-diff-component2 @@ -0,0 +1,5 @@ +Significance: patch +Type: fix +Comment: Move clearQueue call to inside an useEffect since it was updating a component while rendering another component + +