From c515d6f782b95721c94c8bdd2f5626920c8f18cc Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Mon, 2 Oct 2023 18:55:36 +0800 Subject: [PATCH] convert to a simple var --- .../DisplayNames/DisplayNamesWithTooltip.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/components/DisplayNames/DisplayNamesWithTooltip.js b/src/components/DisplayNames/DisplayNamesWithTooltip.js index c8a3a3a1f37f..0e8c435f4457 100644 --- a/src/components/DisplayNames/DisplayNamesWithTooltip.js +++ b/src/components/DisplayNames/DisplayNamesWithTooltip.js @@ -1,6 +1,7 @@ -import React, {Fragment, useCallback, useEffect, useRef, useState} from 'react'; +import React, {Fragment, useCallback, useRef} from 'react'; import {View} from 'react-native'; import _ from 'underscore'; +import lodashGet from 'lodash/get'; import styles from '../../styles/styles'; import Text from '../Text'; import Tooltip from '../Tooltip'; @@ -10,13 +11,7 @@ import {defaultProps, propTypes} from './displayNamesPropTypes'; function DisplayNamesWithToolTip(props) { const containerRef = useRef(null); const childRefs = useRef([]); - const [isEllipsisActive, setIsEllipsisActive] = useState(false); - - useEffect(() => { - setIsEllipsisActive( - containerRef.current && containerRef.current.offsetWidth && containerRef.current.scrollWidth && containerRef.current.offsetWidth < containerRef.current.scrollWidth, - ); - }, []); + const isEllipsisActive = lodashGet(containerRef.current, 'offsetWidth') < lodashGet(containerRef.current, 'scrollWidth'); /** * We may need to shift the Tooltip horizontally as some of the inline text wraps well with ellipsis,