From 9c7b3b68153d62c5f7564bd250d7e0c77cbe1a76 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 15 Aug 2024 17:04:30 +0800 Subject: [PATCH 1/2] fix console error when paying invoice as business --- src/components/PopoverMenu.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/PopoverMenu.tsx b/src/components/PopoverMenu.tsx index e9df68d43d06..ea9bbc702fbe 100644 --- a/src/components/PopoverMenu.tsx +++ b/src/components/PopoverMenu.tsx @@ -1,6 +1,6 @@ import lodashIsEqual from 'lodash/isEqual'; import type {RefObject} from 'react'; -import React, {useEffect, useState} from 'react'; +import React, {useLayoutEffect, useState} from 'react'; import {StyleSheet, View} from 'react-native'; import type {ModalProps} from 'react-native-modal'; import useArrowKeyFocusManager from '@hooks/useArrowKeyFocusManager'; @@ -194,7 +194,10 @@ function PopoverMenu({ setFocusedIndex(-1); }; - useEffect(() => { + // When the menu items are changed, we want to reset the sub-menu to make sure + // we are not accessing the wrong sub-menu parent or possibly undefined when rendering the back button. + // We use useLayoutEffect so the reset happens before the repaint + useLayoutEffect(() => { if (menuItems.length === 0) { return; } From 01a1ed34f1fdf881762582ea17ec794c901e83e5 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 15 Aug 2024 17:45:23 +0800 Subject: [PATCH 2/2] prettier --- src/components/PopoverMenu.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/PopoverMenu.tsx b/src/components/PopoverMenu.tsx index ea9bbc702fbe..0846e27100da 100644 --- a/src/components/PopoverMenu.tsx +++ b/src/components/PopoverMenu.tsx @@ -194,7 +194,7 @@ function PopoverMenu({ setFocusedIndex(-1); }; - // When the menu items are changed, we want to reset the sub-menu to make sure + // When the menu items are changed, we want to reset the sub-menu to make sure // we are not accessing the wrong sub-menu parent or possibly undefined when rendering the back button. // We use useLayoutEffect so the reset happens before the repaint useLayoutEffect(() => {