Skip to content

Commit

Permalink
Prevent infinite redirect after processing site during onboarding flow
Browse files Browse the repository at this point in the history
  • Loading branch information
paulopmt1 committed Jan 8, 2025
1 parent 4298e74 commit 69c05d3
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from '@automattic/onboarding';
import { useSelect } from '@wordpress/data';
import { useI18n } from '@wordpress/react-i18n';
import { defer } from 'lodash';
import { useEffect, useState } from 'react';
import DocumentHead from 'calypso/components/data/document-head';
import { LoadingBar } from 'calypso/components/loading-bar';
Expand Down Expand Up @@ -135,7 +136,10 @@ const ProcessingStep: React.FC< ProcessingStepProps > = function ( props ) {
} );

// Default processing handler.
submit?.( destinationState, ProcessingResult.SUCCESS );
setHasActionSuccessfullyRun( false );

// By deffering the execution we give React time to update the hasActionSuccessfullyRun value and avoid multiple calls.
defer( () => submit?.( destinationState, ProcessingResult.SUCCESS ) );
}
// A change in submit() doesn't cause this effect to rerun.
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down

0 comments on commit 69c05d3

Please sign in to comment.