Skip to content

Commit 4f93df8

Browse files
committed
Fix migration fatal error
1 parent 7346431 commit 4f93df8

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/app/steps/Migration/MigrationStep.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { useCallback } from 'react';
2-
import { useDispatch, useSelect } from '@wordpress/data';
1+
import { useCallback } from '@wordpress/element';
2+
import { dispatch, useSelect } from '@wordpress/data';
33
import { Container, Title, Spinner } from '@newfold/ui-component-library';
44
import { ExclamationCircleIcon } from '@heroicons/react/24/solid';
55
import { nfdOnboardingStore } from '@/data/store';
@@ -14,7 +14,6 @@ const MigrationStep = () => {
1414
isLoading: true,
1515
error: false,
1616
} );
17-
const setInstaWpMigrationUrl = useDispatch( nfdOnboardingStore ).setInstaWpMigrationUrl;
1817

1918
const { canMigrateSite, brandName } = useSelect( ( select ) => {
2019
return {
@@ -46,10 +45,6 @@ const MigrationStep = () => {
4645
);
4746
};
4847

49-
useEffect( () => {
50-
prepareMigration();
51-
}, [ prepareMigration ] );
52-
5348
const prepareMigration = useCallback( async () => {
5449
try {
5550
if ( ! canMigrateSite ) {
@@ -62,7 +57,7 @@ const MigrationStep = () => {
6257

6358
// On success
6459
if ( migrateUrl ) {
65-
setInstaWpMigrationUrl( migrateUrl );
60+
dispatch( nfdOnboardingStore ).setInstaWpMigrationUrl( migrateUrl );
6661
await trackMigrationInitiatedEvent( migrateUrl );
6762

6863
// Open migration url (external)
@@ -87,18 +82,22 @@ const MigrationStep = () => {
8782
)
8883
);
8984
}
90-
}, [ canMigrateSite, setInstaWpMigrationUrl ] );
85+
}, [ canMigrateSite ] );
86+
87+
useEffect( () => {
88+
prepareMigration();
89+
}, [ prepareMigration ] );
9190

9291
/**
9392
* @return { string } The title content
9493
*/
95-
const getTitleContent = () => {
94+
const getTitleContent = useCallback( () => {
9695
return sprintf(
9796
/* translators: %s: to replace brand name */
9897
__( "Let's migrate your existing site to %s", 'wp-module-onboarding' ),
9998
brandName
10099
);
101-
};
100+
}, [ brandName ] );
102101

103102
/**
104103
* Render the migration status

0 commit comments

Comments
 (0)