File tree Expand file tree Collapse file tree 1 file changed +20
-9
lines changed Expand file tree Collapse file tree 1 file changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -38,9 +38,23 @@ export default function App({ optOutUrl }: OptOutUrl) {
3838 const handleSubmit = async ( e : SubmitEvent ) => {
3939 e . preventDefault ( )
4040 dispatch ( submitCreator ( e . target ) )
41- if ( result === Result . invalid || result === Result . blocked ) return
42-
4341 if ( isKeepLogin ) saveAccountInfo ( getElementValues ( e . target ) )
42+ }
43+
44+ useEffect ( ( ) => {
45+ setKeepLogin ( isKeepLogin )
46+ submitWhenKeepLogin ( )
47+ } , [ isKeepLogin ] )
48+
49+ useEffect ( ( ) => {
50+ if (
51+ result === Result . idle ||
52+ result === Result . invalid ||
53+ result === Result . blocked
54+ ) {
55+ // prettier-ignore
56+ return
57+ }
4458
4559 if ( result === Result . correct ) {
4660 location . href = 'main.do'
@@ -52,13 +66,10 @@ export default function App({ optOutUrl }: OptOutUrl) {
5266 return
5367 }
5468
55- throw Error ( 'Unexpect state flow in handleSubmit' )
56- }
57-
58- useEffect ( ( ) => {
59- setKeepLogin ( isKeepLogin )
60- submitWhenKeepLogin ( )
61- } , [ isKeepLogin ] )
69+ throw Error (
70+ `Unexpect result flow in handleSubmit' current value: ${ Result [ result ] } `
71+ )
72+ } , [ result ] )
6273
6374 const onChange = ( ) => {
6475 if ( isWrong ) dispatch ( IDLE )
You can’t perform that action at this time.
0 commit comments