Skip to content

Commit 5b83a4b

Browse files
authored
Merge pull request #47488 from bernhardoj/fix/47187-pay-invoice-as-business-show-console-error
2 parents a07cce4 + 01a1ed3 commit 5b83a4b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/components/PopoverMenu.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import lodashIsEqual from 'lodash/isEqual';
22
import type {RefObject} from 'react';
3-
import React, {useEffect, useState} from 'react';
3+
import React, {useLayoutEffect, useState} from 'react';
44
import {StyleSheet, View} from 'react-native';
55
import type {ModalProps} from 'react-native-modal';
66
import useArrowKeyFocusManager from '@hooks/useArrowKeyFocusManager';
@@ -194,7 +194,10 @@ function PopoverMenu({
194194
setFocusedIndex(-1);
195195
};
196196

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(() => {
198201
if (menuItems.length === 0) {
199202
return;
200203
}

0 commit comments

Comments
 (0)