File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
src/app/will-it-cors/components/steps Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 11'use client' ;
22
3+ import { useEffect } from 'react' ;
4+
35import { observer } from 'mobx-react-lite' ;
46import { useRouter } from 'next/navigation' ;
57
@@ -32,8 +34,14 @@ export const Steps = observer(({ currentStep }: { currentStep: WillItCorsSteps }
3234
3335 // If you end up directly on a step without having completed the path this session (e.g.
3436 // if you refresh the page or navigate there directly), we redirect you to the root.
35- if ( currentStep !== 'source-url' && ! steps . sourceUrl ) {
36- router . push ( '/will-it-cors/' ) ;
37+ const shouldRedirect = currentStep !== 'source-url' && ! steps . sourceUrl ;
38+ useEffect ( ( ) => {
39+ if ( shouldRedirect ) {
40+ router . push ( '/will-it-cors/' ) ;
41+ }
42+ } , [ shouldRedirect , router ] ) ;
43+
44+ if ( shouldRedirect ) {
3745 return null ;
3846 }
3947
You can’t perform that action at this time.
0 commit comments