Fix infinite redirect from homescreen to core profiler (#38768)

* Fix infinite redirect using useEffect to remove unintentional rerendering

* Changelog
This commit is contained in:
Ilyas Foo 2023-06-16 20:28:25 +08:00 committed by GitHub
parent 6b86fc64de
commit 0a50173976
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -3,12 +3,14 @@
*/
import { compose } from '@wordpress/compose';
import { withSelect } from '@wordpress/data';
import { useEffect } from '@wordpress/element';
import {
ONBOARDING_STORE_NAME,
withOnboardingHydration,
WCDataSelector,
} from '@woocommerce/data';
import { getHistory, getNewPath, useQuery } from '@woocommerce/navigation';
/**
* Internal dependencies
*/
@ -26,9 +28,15 @@ const Homescreen = ( {
} = {},
hasFinishedResolution,
}: HomescreenProps ) => {
if ( hasFinishedResolution && ! profilerCompleted && ! profilerSkipped ) {
getHistory().push( getNewPath( {}, '/setup-wizard', {} ) );
}
useEffect( () => {
if (
hasFinishedResolution &&
! profilerCompleted &&
! profilerSkipped
) {
getHistory().push( getNewPath( {}, '/setup-wizard', {} ) );
}
}, [ hasFinishedResolution, profilerCompleted, profilerSkipped ] );
const query = useQuery();
// @ts-expect-error Layout is a pure JS component

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fix infinite redirect from homescreen when onboarding isn't completed using useEffect to remove unintentional rerendering