Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor reportAction of context menu #26741

Merged
merged 14 commits into from
Sep 11, 2023
Merged
Prev Previous commit
Next Next commit
use lodashGet
  • Loading branch information
dukenv0307 committed Sep 5, 2023
commit 2c3260aec48f90486deaee0692adb1ce04e9bea3
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, {useMemo, useState, memo} from 'react';
import {InteractionManager, View} from 'react-native';
import lodashGet from 'lodash/get';
import _ from 'underscore';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
@@ -134,8 +135,8 @@ export default compose(
}),
)(
memo(BaseReportActionContextMenu, (prevProps, nextProps) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add code comments to explain why this memo is here and what it's purpose is?

const prevReportAction = prevProps.reportActions[prevProps.reportActionID];
const nextReportAction = nextProps.reportActions[nextProps.reportActionID];
const prevReportAction = lodashGet(prevProps.reportActions, prevProps.reportActionID, '');
const nextReportAction = lodashGet(nextProps.reportActions, nextProps.reportActionID, '');

if (prevReportAction !== nextReportAction) {
return false;