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' ;
3
3
import { Container , Title , Spinner } from '@newfold/ui-component-library' ;
4
4
import { ExclamationCircleIcon } from '@heroicons/react/24/solid' ;
5
5
import { nfdOnboardingStore } from '@/data/store' ;
@@ -14,7 +14,6 @@ const MigrationStep = () => {
14
14
isLoading : true ,
15
15
error : false ,
16
16
} ) ;
17
- const setInstaWpMigrationUrl = useDispatch ( nfdOnboardingStore ) . setInstaWpMigrationUrl ;
18
17
19
18
const { canMigrateSite, brandName } = useSelect ( ( select ) => {
20
19
return {
@@ -46,10 +45,6 @@ const MigrationStep = () => {
46
45
) ;
47
46
} ;
48
47
49
- useEffect ( ( ) => {
50
- prepareMigration ( ) ;
51
- } , [ prepareMigration ] ) ;
52
-
53
48
const prepareMigration = useCallback ( async ( ) => {
54
49
try {
55
50
if ( ! canMigrateSite ) {
@@ -62,7 +57,7 @@ const MigrationStep = () => {
62
57
63
58
// On success
64
59
if ( migrateUrl ) {
65
- setInstaWpMigrationUrl ( migrateUrl ) ;
60
+ dispatch ( nfdOnboardingStore ) . setInstaWpMigrationUrl ( migrateUrl ) ;
66
61
await trackMigrationInitiatedEvent ( migrateUrl ) ;
67
62
68
63
// Open migration url (external)
@@ -87,18 +82,22 @@ const MigrationStep = () => {
87
82
)
88
83
) ;
89
84
}
90
- } , [ canMigrateSite , setInstaWpMigrationUrl ] ) ;
85
+ } , [ canMigrateSite ] ) ;
86
+
87
+ useEffect ( ( ) => {
88
+ prepareMigration ( ) ;
89
+ } , [ prepareMigration ] ) ;
91
90
92
91
/**
93
92
* @return { string } The title content
94
93
*/
95
- const getTitleContent = ( ) => {
94
+ const getTitleContent = useCallback ( ( ) => {
96
95
return sprintf (
97
96
/* translators: %s: to replace brand name */
98
97
__ ( "Let's migrate your existing site to %s" , 'wp-module-onboarding' ) ,
99
98
brandName
100
99
) ;
101
- } ;
100
+ } , [ brandName ] ) ;
102
101
103
102
/**
104
103
* Render the migration status
0 commit comments