@@ -25,10 +25,9 @@ export const JwtInputComponent: React.FC<JwtInputComponentProps> = ({
2525  languageCode, 
2626  dictionary, 
2727} )  =>  { 
28-   const  [ autoFocusEnabled ,  setAutofocusEnabled ]  =  useState ( ( )  =>  { 
29-     const  saved  =  localStorage . getItem ( "autofocus-enabled" ) ; 
30-     return  saved  ? ! ! JSON . parse ( saved )  : false 
31-   } ) ; 
28+   const  [ autoFocusEnabled ,  setAutofocusEnabled ]  =  useState < boolean  |  undefined > ( 
29+     undefined 
30+   ) ; 
3231  const  handleJwtChange$  =  useDecoderStore ( ( state )  =>  state . handleJwtChange ) ; 
3332  const  jwt$  =  useDecoderStore ( ( state )  =>  state . jwt ) ; 
3433  const  decodeErrors$  =  useDecoderStore ( ( state )  =>  state . decodingErrors ) ; 
@@ -52,9 +51,14 @@ export const JwtInputComponent: React.FC<JwtInputComponentProps> = ({
5251  } ; 
5352
5453  const  handleCheckboxChange  =  ( selected : boolean )  =>  { 
55-     localStorage . setItem ( "autofocus-enabled" ,  JSON . stringify ( selected ) ) 
56-     setAutofocusEnabled ( selected ) 
57-   } 
54+     localStorage . setItem ( "autofocus-enabled" ,  JSON . stringify ( selected ) ) ; 
55+     setAutofocusEnabled ( selected ) ; 
56+   } ; 
57+ 
58+   useEffect ( ( )  =>  { 
59+     const  saved  =  localStorage . getItem ( "autofocus-enabled" ) ; 
60+     setAutofocusEnabled ( saved  ? ! ! JSON . parse ( saved )  : false ) ; 
61+   } ,  [ ] ) ; 
5862
5963  useEffect ( ( )  =>  { 
6064    setToken ( jwt$ ) ; 
@@ -64,7 +68,10 @@ export const JwtInputComponent: React.FC<JwtInputComponentProps> = ({
6468    < > 
6569      < div  style = { {  display : "flex" ,  justifyContent : "space-between"  } } > 
6670        < span  className = { styles . headline } > { dictionary . headline } </ span > 
67-         < CheckboxComponent  isSelected = { autoFocusEnabled }  onChange = { e  =>  handleCheckboxChange ( e ) } > 
71+         < CheckboxComponent 
72+           isSelected = { autoFocusEnabled } 
73+           onChange = { ( e )  =>  handleCheckboxChange ( e ) } 
74+         > 
6875          < span  className = { styles . checkbox__label } > Enable auto-focus</ span > 
6976        </ CheckboxComponent > 
7077      </ div > 
@@ -99,7 +106,13 @@ export const JwtInputComponent: React.FC<JwtInputComponentProps> = ({
99106          ) , 
100107        } } 
101108      > 
102-         < JwtEditorComponent  token = { token }  handleJwtChange = { handleJwtChange }  autoFocus = { autoFocusEnabled } /> 
109+         { autoFocusEnabled  !==  undefined  ? ( 
110+           < JwtEditorComponent 
111+             token = { token } 
112+             handleJwtChange = { handleJwtChange } 
113+             autoFocus = { autoFocusEnabled } 
114+           /> 
115+         )  : null } 
103116      </ CardComponent > 
104117    </ > 
105118  ) ; 
0 commit comments