Skip to content

Commit 4c438e1

Browse files
committed
fix: use FC over JSX to support React 18
1 parent 2ad5f4f commit 4c438e1

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

src/PrismicNextImage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { JSX } from "react";
3+
import { FC } from "react";
44
import Image, { ImageProps } from "next/image";
55
import { buildURL, ImgixURLParams } from "imgix-url-builder";
66
import { ImageFieldImage, isFilled } from "@prismicio/client";
@@ -80,7 +80,7 @@ export type PrismicNextImageProps = Omit<
8080
*
8181
* @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image
8282
*/
83-
export const PrismicNextImage = ({
83+
export const PrismicNextImage: FC<PrismicNextImageProps> = ({
8484
field,
8585
imgixParams = {},
8686
alt,
@@ -91,7 +91,7 @@ export const PrismicNextImage = ({
9191
fallback = null,
9292
loader = imgixLoader,
9393
...restProps
94-
}: PrismicNextImageProps): JSX.Element => {
94+
}) => {
9595
if (DEV) {
9696
if (typeof alt === "string" && alt !== "") {
9797
console.warn(

src/PrismicPreview.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ReactNode, JSX } from "react";
1+
import type { FC, ReactNode } from "react";
22
import Script from "next/script";
33
import { getToolbarSrc } from "@prismicio/client";
44

@@ -37,9 +37,7 @@ export type PrismicPreviewProps = {
3737
* This component can be wrapped around your app or added anywhere in your app's
3838
* tree. It must be rendered on every page.
3939
*/
40-
export async function PrismicPreview(
41-
props: PrismicPreviewProps,
42-
): Promise<JSX.Element> {
40+
export const PrismicPreview: FC<PrismicPreviewProps> = async (props) => {
4341
const { repositoryName, children, ...otherProps } = props;
4442

4543
// Need this to avoid the following Next.js build-time error:
@@ -61,4 +59,4 @@ export async function PrismicPreview(
6159
<Script src={toolbarSrc} strategy="lazyOnload" />
6260
</>
6361
);
64-
}
62+
};

src/PrismicPreviewClient.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { useEffect } from "react";
3+
import { FC, useEffect } from "react";
44
import { cookie as prismicCookie } from "@prismicio/client";
55
import { useRouter } from "next/navigation";
66

@@ -11,7 +11,7 @@ type PrismicPreviewClientProps = {
1111
exitPreviewURL?: string;
1212
};
1313

14-
export function PrismicPreviewClient(props: PrismicPreviewClientProps): null {
14+
export const PrismicPreviewClient: FC<PrismicPreviewClientProps> = (props) => {
1515
const {
1616
repositoryName,
1717
isDraftMode,
@@ -97,7 +97,7 @@ export function PrismicPreviewClient(props: PrismicPreviewClientProps): null {
9797
}, [repositoryName, isDraftMode, updatePreviewURL, exitPreviewURL, refresh]);
9898

9999
return null;
100-
}
100+
};
101101

102102
/**
103103
* Returns the value of a cookie from a given cookie store.

src/pages/PrismicPreview.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type ReactNode, useEffect, JSX } from "react";
1+
import { type ReactNode, useEffect, FC } from "react";
22
import { useRouter } from "next/router";
33
import Script from "next/script";
44
import { getToolbarSrc, cookie as prismicCookie } from "@prismicio/client";
@@ -36,7 +36,7 @@ export type PrismicPreviewProps = {
3636
* This component can be wrapped around your app or added anywhere in your app's
3737
* tree. It must be rendered on every page.
3838
*/
39-
export function PrismicPreview(props: PrismicPreviewProps): JSX.Element {
39+
export const PrismicPreview: FC<PrismicPreviewProps> = (props) => {
4040
const {
4141
repositoryName,
4242
updatePreviewURL = "/api/preview",
@@ -132,7 +132,7 @@ export function PrismicPreview(props: PrismicPreviewProps): JSX.Element {
132132
<Script src={toolbarSrc} strategy="lazyOnload" />
133133
</>
134134
);
135-
}
135+
};
136136

137137
function getPreviewCookieRepositoryName() {
138138
const cookie = window.document.cookie

0 commit comments

Comments
 (0)