From cc87d7e839ee891ef4d47efb261419561d134f58 Mon Sep 17 00:00:00 2001 From: Carlos Dario Almonte Date: Thu, 21 Sep 2023 09:42:17 -0400 Subject: [PATCH] refactor: use hook instead of HOC for useWindowDimensions --- src/components/LHNOptionsList/OptionRowLHN.js | 4 +++- src/components/LHNOptionsList/OptionRowLHNData.js | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.js b/src/components/LHNOptionsList/OptionRowLHN.js index 565de806b729..1217caa7d3dd 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.js +++ b/src/components/LHNOptionsList/OptionRowLHN.js @@ -26,6 +26,7 @@ import * as ReportUtils from '../../libs/ReportUtils'; import useLocalize from '../../hooks/useLocalize'; import Permissions from '../../libs/Permissions'; import Tooltip from '../Tooltip'; +import useWindowDimensions from '../../hooks/useWindowDimensions'; const propTypes = { /** Style for hovered state */ @@ -67,6 +68,7 @@ const defaultProps = { function OptionRowLHN(props) { const popoverAnchor = useRef(null); const isFocusedRef = useRef(true); + const {isSmallScreenWidth} = useWindowDimensions(); const {translate} = useLocalize(); @@ -113,7 +115,7 @@ function OptionRowLHN(props) { useCallback(() => { isFocusedRef.current = true; return () => { - if (!props.isSmallScreenWidth) { + if (!isSmallScreenWidth) { return; } isFocusedRef.current = false; diff --git a/src/components/LHNOptionsList/OptionRowLHNData.js b/src/components/LHNOptionsList/OptionRowLHNData.js index a474179313b6..2c51d6332946 100644 --- a/src/components/LHNOptionsList/OptionRowLHNData.js +++ b/src/components/LHNOptionsList/OptionRowLHNData.js @@ -18,7 +18,6 @@ import * as TransactionUtils from '../../libs/TransactionUtils'; import participantPropTypes from '../participantPropTypes'; import CONST from '../../CONST'; import reportActionPropTypes from '../../pages/home/report/reportActionPropTypes'; -import withWindowDimensions, {windowDimensionsPropTypes} from '../withWindowDimensions'; const propTypes = { /** If true will disable ever setting the OptionRowLHN to focused */ @@ -54,7 +53,6 @@ const propTypes = { }), ...withCurrentReportIDPropTypes, - ...windowDimensionsPropTypes, ...basePropTypes, }; @@ -217,6 +215,5 @@ export default React.memo( `${ONYXKEYS.COLLECTION.TRANSACTION}${lodashGet(parentReportActions, [fullReport.parentReportActionID, 'originalMessage', 'IOUTransactionID'], '')}`, }, }), - withWindowDimensions, )(OptionRowLHNData), );