This repository was archived by the owner on Dec 3, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -34,9 +34,10 @@ export function useNavigationEvents(handleEvt) {
3434 } ,
3535 // For TODO consideration: If the events are tied to the navigation object and the key
3636 // identifies the nav object, then we should probably pass [navigation.state.key] here, to
37- // make sure react doesn't needlessly detach and re-attach this effect. Need more thorough
38- // testing to be sure..
37+ // make sure react doesn't needlessly detach and re-attach this effect. In practice this
38+ // seems to cause troubles
3939 undefined
40+ // [navigation.state.key]
4041 ) ;
4142}
4243
@@ -60,8 +61,10 @@ function focusStateOfEvent(eventName) {
6061 return willFocusState ;
6162 case 'willBlur' :
6263 return willBlurState ;
63- default :
64+ case 'didBlur' :
6465 return didBlurState ;
66+ default :
67+ return null ;
6568 }
6669}
6770
@@ -70,7 +73,8 @@ export function useFocusState() {
7073 const isFocused = navigation . isFocused ( ) ;
7174 const [ focusState , setFocusState ] = useState ( getInitialFocusState ( isFocused ) ) ;
7275 function handleEvt ( e ) {
73- setFocusState ( focusStateOfEvent ( e . type ) ) ;
76+ const newState = focusStateOfEvent ( e . type ) ;
77+ newState && setFocusState ( newState ) ;
7478 }
7579 useNavigationEvents ( handleEvt ) ;
7680 return focusState ;
You can’t perform that action at this time.
0 commit comments