From f4dfa06b3b917fba3a9dd4837ddc9baa6f2d85f5 Mon Sep 17 00:00:00 2001 From: ZivSa1 Date: Wed, 29 Apr 2026 17:05:44 +0300 Subject: [PATCH] FloatingButton - improve initial visibility handling with useRef --- .../src/components/floatingButton/index.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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;