Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix clicking pay button for invoices raise an null error #46317

Merged
merged 13 commits into from
Aug 2, 2024
Merged
4 changes: 3 additions & 1 deletion src/components/ButtonWithDropdownMenu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type {MutableRefObject} from 'react';
import React, {useEffect, useRef, useState} from 'react';
import {View} from 'react-native';
import Button from '@components/Button';
Expand Down Expand Up @@ -45,6 +46,7 @@ function ButtonWithDropdownMenu<IValueType>({
const selectedItem = options[selectedItemIndex] || options[0];
const innerStyleDropButton = StyleUtils.getDropDownButtonHeight(buttonSize);
const isButtonSizeLarge = buttonSize === CONST.DROPDOWN_BUTTON_SIZE.LARGE;
const nullCheckRef = (ref: MutableRefObject<View | null>) => ref ?? null;

useEffect(() => {
if (!caretButton.current) {
Expand Down Expand Up @@ -139,7 +141,7 @@ function ButtonWithDropdownMenu<IValueType>({
onClose={() => setIsMenuVisible(false)}
onItemSelected={() => setIsMenuVisible(false)}
anchorPosition={popoverAnchorPosition}
anchorRef={caretButton}
anchorRef={nullCheckRef(caretButton)}
withoutOverlay
anchorAlignment={anchorAlignment}
headerText={menuHeaderText}
Expand Down
Loading