Skip to content

Commit

Permalink
Merge pull request #30406 from janicduplessis/@janic/header-memo
Browse files Browse the repository at this point in the history
Memo HeaderView
  • Loading branch information
Gonals committed Oct 26, 2023
2 parents 91642d2 + 6007e60 commit a67253b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
40 changes: 21 additions & 19 deletions src/pages/home/HeaderView.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import React from 'react';
import React, {memo} from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
Expand Down Expand Up @@ -271,21 +271,23 @@ HeaderView.propTypes = propTypes;
HeaderView.displayName = 'HeaderView';
HeaderView.defaultProps = defaultProps;

export default compose(
withWindowDimensions,
withLocalize,
withOnyx({
guideCalendarLink: {
key: ONYXKEYS.ACCOUNT,
selector: (account) => (account && account.guideCalendarLink) || null,
initialValue: null,
},
parentReport: {
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID || report.reportID}`,
selector: reportWithoutHasDraftSelector,
},
session: {
key: ONYXKEYS.SESSION,
},
}),
)(HeaderView);
export default memo(
compose(
withWindowDimensions,
withLocalize,
withOnyx({
guideCalendarLink: {
key: ONYXKEYS.ACCOUNT,
selector: (account) => (account && account.guideCalendarLink) || null,
initialValue: null,
},
parentReport: {
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID || report.reportID}`,
selector: reportWithoutHasDraftSelector,
},
session: {
key: ONYXKEYS.SESSION,
},
}),
)(HeaderView),
);
6 changes: 5 additions & 1 deletion src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,14 @@ function ReportScreen({
const isTopMostReportId = currentReportID === getReportID(route);
const didSubscribeToReportLeavingEvents = useRef(false);

const goBack = useCallback(() => {
Navigation.goBack(ROUTES.HOME, false, true);
}, []);

let headerView = (
<HeaderView
reportID={reportID}
onNavigationMenuButtonClicked={() => Navigation.goBack(ROUTES.HOME, false, true)}
onNavigationMenuButtonClicked={goBack}
personalDetails={personalDetails}
report={report}
/>
Expand Down

0 comments on commit a67253b

Please sign in to comment.