From 8a693f17c22336ed2dbbb71072b6eb933adf94b3 Mon Sep 17 00:00:00 2001 From: Robert Reinhard Date: Wed, 20 Nov 2024 09:25:00 -0800 Subject: [PATCH] Switch to ReactNode return types --- packages/contentful/src/ContentfulVisual.tsx | 3 ++- packages/next/src/NextVisual.tsx | 8 +++----- packages/react/src/LazyVideo/AccessibilityControls.tsx | 4 ++-- packages/react/src/LazyVideo/LazyVideoClient.tsx | 6 +++--- packages/react/src/LazyVideo/LazyVideoServer.tsx | 3 ++- packages/react/src/PictureImage.tsx | 5 +++-- packages/react/src/ReactVisual.tsx | 6 ++---- packages/react/src/VisualWrapper.tsx | 6 +++--- packages/sanity-next/src/SanityNextVisual.tsx | 6 ++---- 9 files changed, 22 insertions(+), 25 deletions(-) diff --git a/packages/contentful/src/ContentfulVisual.tsx b/packages/contentful/src/ContentfulVisual.tsx index 7683e5f..4d8e612 100644 --- a/packages/contentful/src/ContentfulVisual.tsx +++ b/packages/contentful/src/ContentfulVisual.tsx @@ -12,11 +12,12 @@ import { hasResponsiveAssets, hasResponsiveAspects } from './lib/aspectRatio' +import type { ReactNode } from 'react' // Render a Visual using Contentful data export default function ContentfulVisual( props: ContentfulVisualProps -): JSX.Element | null { +): ReactNode { // Destructure some props const { diff --git a/packages/next/src/NextVisual.tsx b/packages/next/src/NextVisual.tsx index 90297df..4e35a2d 100644 --- a/packages/next/src/NextVisual.tsx +++ b/packages/next/src/NextVisual.tsx @@ -11,12 +11,10 @@ import { } from '@react-visual/react' import { NextVisualProps } from './types/nextVisualTypes' +import type { ReactNode } from 'react' // Render a Sanity image via Next/Image -export default function NextVisual( - props: NextVisualProps -): JSX.Element | null { - +export default function NextVisual(props: NextVisualProps): ReactNode { // Destructure props const { image, @@ -88,7 +86,7 @@ function NextImage({ priority, loader, placeholderData, -}: any): JSX.Element { +}: any): ReactNode { return ( ; } diff --git a/packages/react/src/ReactVisual.tsx b/packages/react/src/ReactVisual.tsx index 83c0403..4d2f73e 100644 --- a/packages/react/src/ReactVisual.tsx +++ b/packages/react/src/ReactVisual.tsx @@ -5,11 +5,9 @@ import PictureImage from './PictureImage' import { collectDataAttributes } from './lib/attributes' import { ReactVisualProps } from './types/reactVisualTypes' import { fillStyles } from './lib/styles' +import type { ReactNode } from 'react' -export default function ReactVisual( - props: ReactVisualProps -): JSX.Element | null { - +export default function ReactVisual(props: ReactVisualProps): ReactNode { // Destructure props const { image, diff --git a/packages/react/src/VisualWrapper.tsx b/packages/react/src/VisualWrapper.tsx index 28185b8..dbe64ad 100644 --- a/packages/react/src/VisualWrapper.tsx +++ b/packages/react/src/VisualWrapper.tsx @@ -1,4 +1,4 @@ -import type { CSSProperties } from 'react' +import type { CSSProperties, ReactNode } from 'react' import { fillStyles, cx } from './lib/styles' import { isNumeric } from './lib/values' import type { VisualWrapperProps } from './types/visualWrapperTypes' @@ -24,7 +24,7 @@ export default function VisualWrapper({ className, style, dataAttributes, -}: VisualWrapperProps): JSX.Element { +}: VisualWrapperProps): ReactNode { // If aspect is a function, invoke it to determine the aspect ratio let aspectRatio, aspectStyleTag, aspectClasses if (typeof aspect == 'function' && sourceMedia && sourceMedia.length) { @@ -64,7 +64,7 @@ function makeResponsiveAspects({ video, }: MakeResponsiveAspectsProps): { aspectClasses: string; - aspectStyleTag: JSX.Element; + aspectStyleTag: ReactNode; } { // Make CSS classes and related rules that are specific to the query and diff --git a/packages/sanity-next/src/SanityNextVisual.tsx b/packages/sanity-next/src/SanityNextVisual.tsx index ae55f4f..7936f4a 100644 --- a/packages/sanity-next/src/SanityNextVisual.tsx +++ b/packages/sanity-next/src/SanityNextVisual.tsx @@ -7,11 +7,9 @@ import { placeholderFromSource, } from './lib/sourceMapping' import { SanityNextVisualProps } from './types/sanityNextVisualTypes' +import type { ReactNode } from 'react' -export default function SanityNextVisual( - props: SanityNextVisualProps -): JSX.Element | null { - +export default function SanityNextVisual(props: SanityNextVisualProps): ReactNode { // Destructure some props let {