From 170799d29c76b8b8844f80e57e8db0fe87789955 Mon Sep 17 00:00:00 2001 From: Josh <37798644+joshuaellis@users.noreply.github.com> Date: Tue, 9 Jan 2024 10:59:30 +0000 Subject: [PATCH] fix(helper-plugin): memoize GenericInput for performance issues (#19177) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Madhuri Sandbhor Co-authored-by: RĂ©mi de Juvigny <8087692+remidej@users.noreply.github.com> --- .../core/helper-plugin/src/components/GenericInput.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/core/helper-plugin/src/components/GenericInput.tsx b/packages/core/helper-plugin/src/components/GenericInput.tsx index bd1056676ca..e1a27dbaf56 100644 --- a/packages/core/helper-plugin/src/components/GenericInput.tsx +++ b/packages/core/helper-plugin/src/components/GenericInput.tsx @@ -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'; @@ -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 };