Skip to content

Commit

Permalink
Merge pull request #26217 from adamgrzybowski/@wolewicki/personal-det…
Browse files Browse the repository at this point in the history
…ails-performance

fix: check if localize should render
mountiny authored Sep 15, 2023
2 parents d9f35a3 + 354ba4d commit 144e932
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/withCurrentUserPersonalDetails.js
Original file line number Diff line number Diff line change
@@ -36,7 +36,8 @@ export default function (WrappedComponent) {

function WithCurrentUserPersonalDetails(props) {
const accountID = props.session.accountID;
const currentUserPersonalDetails = useMemo(() => ({...props.personalDetails[accountID], accountID}), [props.personalDetails, accountID]);
const accountPersonalDetails = props.personalDetails[accountID];
const currentUserPersonalDetails = useMemo(() => ({...accountPersonalDetails, accountID}), [accountPersonalDetails, accountID]);
return (
<WrappedComponent
// eslint-disable-next-line react/jsx-props-no-spreading
7 changes: 7 additions & 0 deletions src/components/withLocalize.js
Original file line number Diff line number Diff line change
@@ -62,6 +62,13 @@ const localeProviderDefaultProps = {
};

class LocaleContextProvider extends React.Component {
shouldComponentUpdate(nextProps) {
return (
nextProps.preferredLocale !== this.props.preferredLocale ||
lodashGet(nextProps, 'currentUserPersonalDetails.timezone.selected') !== lodashGet(this.props, 'currentUserPersonalDetails.timezone.selected')
);
}

/**
* The context this component exposes to child components
* @returns {object} translation util functions and locale

0 comments on commit 144e932

Please sign in to comment.