Skip to content

Commit

Permalink
fix(helper-plugin): memoize GenericInput for performance issues (#19177)
Browse files Browse the repository at this point in the history
Co-authored-by: Madhuri Sandbhor <madhurisandbhor@gmail.com>
Co-authored-by: Rémi de Juvigny <8087692+remidej@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 9, 2024
1 parent 25d2a8f commit 170799d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/core/helper-plugin/src/components/GenericInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
} from '@strapi/design-system';
import { Eye, EyeStriked } from '@strapi/icons';
import formatISO from 'date-fns/formatISO';
import isEqual from 'lodash/isEqual';
import { useIntl } from 'react-intl';

import { FieldSchema, useFieldHint } from '../hooks/useFieldHint';
Expand Down Expand Up @@ -559,4 +560,11 @@ const GenericInput = ({
}
};

export { GenericInput };
/**
* we've memoized this component because we use a context to store all the data in our form in the content-manager.
* This then causes _every_ component to re-render because there are no selects incurring performance issues
* in content-types as the content-type gets more complicated.
*/
const MemoizedGenericInput = React.memo(GenericInput, isEqual);

export { MemoizedGenericInput as GenericInput };

0 comments on commit 170799d

Please sign in to comment.