Skip to content

Commit

Permalink
refactor: use hook instead of HOC for useWindowDimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
redpanda-bit committed Sep 26, 2023
1 parent 719964d commit cc87d7e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/components/LHNOptionsList/OptionRowLHN.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -67,6 +68,7 @@ const defaultProps = {
function OptionRowLHN(props) {
const popoverAnchor = useRef(null);
const isFocusedRef = useRef(true);
const {isSmallScreenWidth} = useWindowDimensions();

const {translate} = useLocalize();

Expand Down Expand Up @@ -113,7 +115,7 @@ function OptionRowLHN(props) {
useCallback(() => {
isFocusedRef.current = true;
return () => {
if (!props.isSmallScreenWidth) {
if (!isSmallScreenWidth) {
return;
}
isFocusedRef.current = false;
Expand Down
3 changes: 0 additions & 3 deletions src/components/LHNOptionsList/OptionRowLHNData.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -54,7 +53,6 @@ const propTypes = {
}),

...withCurrentReportIDPropTypes,
...windowDimensionsPropTypes,
...basePropTypes,
};

Expand Down Expand Up @@ -217,6 +215,5 @@ export default React.memo(
`${ONYXKEYS.COLLECTION.TRANSACTION}${lodashGet(parentReportActions, [fullReport.parentReportActionID, 'originalMessage', 'IOUTransactionID'], '')}`,
},
}),
withWindowDimensions,
)(OptionRowLHNData),
);

0 comments on commit cc87d7e

Please sign in to comment.