diff --git a/packages/react-native-ui-lib/src/components/floatingButton/index.tsx b/packages/react-native-ui-lib/src/components/floatingButton/index.tsx index 7951bda202..64528ce9f4 100644 --- a/packages/react-native-ui-lib/src/components/floatingButton/index.tsx +++ b/packages/react-native-ui-lib/src/components/floatingButton/index.tsx @@ -1,4 +1,4 @@ -import React, {PropsWithChildren, useEffect, useMemo} from 'react'; +import React, {PropsWithChildren, useEffect, useMemo, useRef} from 'react'; import {StyleSheet} from 'react-native'; import {asBaseComponent, Constants} from '../../commons/new'; import {LogService} from '../../services'; @@ -85,6 +85,13 @@ const FloatingButton = (props: FloatingButtonProps) => { testID } = props; + const initialVisibility = useRef(visible); + const firstLoad = useRef(true); + + if (firstLoad.current && visible) { + firstLoad.current = false; + } + useEffect(() => { // eslint-disable-next-line max-len LogService.warn( @@ -107,6 +114,10 @@ const FloatingButton = (props: FloatingButtonProps) => { return null; } + if (firstLoad.current && !initialVisibility.current) { + return null; + } + const renderPrimaryButton = () => { if (!button) { return null;