From c338fb2deab669443a444bb5786a80b8e5980c19 Mon Sep 17 00:00:00 2001 From: Scott Engert Date: Tue, 24 Sep 2024 14:08:19 -0700 Subject: [PATCH] BUGFIX: Recommending fix to minimized React 18 errors with nextjs & defaultProps errors --- packages/sitecore-jss-nextjs/src/components/NextImage.tsx | 6 +----- packages/sitecore-jss-nextjs/src/components/RichText.tsx | 7 +------ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/packages/sitecore-jss-nextjs/src/components/NextImage.tsx b/packages/sitecore-jss-nextjs/src/components/NextImage.tsx index 2d1e8d8ad9..dded07e4a2 100644 --- a/packages/sitecore-jss-nextjs/src/components/NextImage.tsx +++ b/packages/sitecore-jss-nextjs/src/components/NextImage.tsx @@ -20,7 +20,7 @@ export const NextImage: React.FC = ({ fill, priority, ...otherProps -}) => { +} = {editable: true}) => { // next handles src and we use a custom loader, // throw error if these are present if (otherProps.src) { @@ -105,8 +105,4 @@ NextImage.propTypes = { ), }; -NextImage.defaultProps = { - editable: true, -}; - NextImage.displayName = 'NextImage'; diff --git a/packages/sitecore-jss-nextjs/src/components/RichText.tsx b/packages/sitecore-jss-nextjs/src/components/RichText.tsx index a89a2b081a..3197530972 100644 --- a/packages/sitecore-jss-nextjs/src/components/RichText.tsx +++ b/packages/sitecore-jss-nextjs/src/components/RichText.tsx @@ -24,7 +24,7 @@ export type RichTextProps = ReactRichTextProps & { const prefetched: { [cacheKey: string]: boolean } = {}; -export const RichText = (props: RichTextProps): JSX.Element => { +export const RichText = (props: RichTextProps = {tag: 'div', editable: true}): JSX.Element => { const { internalLinksSelector = 'a[href^="/"]', prefetchLinks = true, ...rest } = props; const hasText = props.field && props.field.value; const isEditing = props.editable && props.field && props.field.editable; @@ -77,9 +77,4 @@ RichText.propTypes = { ...RichTextPropTypes, }; -RichText.defaultProps = { - tag: 'div', - editable: true, -}; - RichText.displayName = 'NextRichText';