Move clearQueue call to inside an useEffect (#36626)
* Move clearQueue call to inside an useEffect That call was causing a React error (Cannot update a component while rendering a different component) * Move queueForPage declaration to before it's use
This commit is contained in:
parent
f1981618ad
commit
d5e2ae0474
|
@ -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 (
|
||||
|
|
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue