File tree 1 file changed +5
-2
lines changed
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 1
1
import lodashIsEqual from 'lodash/isEqual' ;
2
2
import type { RefObject } from 'react' ;
3
- import React , { useEffect , useState } from 'react' ;
3
+ import React , { useLayoutEffect , useState } from 'react' ;
4
4
import { StyleSheet , View } from 'react-native' ;
5
5
import type { ModalProps } from 'react-native-modal' ;
6
6
import useArrowKeyFocusManager from '@hooks/useArrowKeyFocusManager' ;
@@ -194,7 +194,10 @@ function PopoverMenu({
194
194
setFocusedIndex ( - 1 ) ;
195
195
} ;
196
196
197
- useEffect ( ( ) => {
197
+ // When the menu items are changed, we want to reset the sub-menu to make sure
198
+ // we are not accessing the wrong sub-menu parent or possibly undefined when rendering the back button.
199
+ // We use useLayoutEffect so the reset happens before the repaint
200
+ useLayoutEffect ( ( ) => {
198
201
if ( menuItems . length === 0 ) {
199
202
return ;
200
203
}
You can’t perform that action at this time.
0 commit comments