From 4ba87520db6cf16ab7fb11129441994b11262269 Mon Sep 17 00:00:00 2001 From: Carlos Kelly Date: Wed, 10 May 2023 11:45:04 -0500 Subject: [PATCH 1/2] Fix live preview types --- .changeset/nice-ligers-leave.md | 5 +++++ .../src/components/Live/LivePreview.tsx | 17 +++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 .changeset/nice-ligers-leave.md diff --git a/.changeset/nice-ligers-leave.md b/.changeset/nice-ligers-leave.md new file mode 100644 index 0000000..66fe2ca --- /dev/null +++ b/.changeset/nice-ligers-leave.md @@ -0,0 +1,5 @@ +--- +"react-live": patch +--- + +Fix live preview types. diff --git a/packages/react-live/src/components/Live/LivePreview.tsx b/packages/react-live/src/components/Live/LivePreview.tsx index 91b288a..034fcc4 100644 --- a/packages/react-live/src/components/Live/LivePreview.tsx +++ b/packages/react-live/src/components/Live/LivePreview.tsx @@ -1,15 +1,16 @@ -import React, { PropsWithChildren, useContext } from "react"; +import React, { useContext } from "react"; import LiveContext from "./LiveContext"; -type Props = { - Component?: React.ComponentType>>; -}; +type Props = { + Component?: T; +} & React.ComponentPropsWithoutRef; -const fallbackComponent = ( - props: PropsWithChildren> -) =>
; +function LivePreview( + props: Props +): JSX.Element; +function LivePreview(props: Props): JSX.Element; -function LivePreview({ Component = fallbackComponent, ...rest }: Props) { +function LivePreview({ Component = "div", ...rest }: Props): JSX.Element { const { element: Element } = useContext(LiveContext); return {Element ? : null}; } From a2f5bd65cb83736a99724f7e1290ac8f027d226c Mon Sep 17 00:00:00 2001 From: Carlos Kelly Date: Wed, 10 May 2023 11:50:39 -0500 Subject: [PATCH 2/2] Add author tag --- .changeset/nice-ligers-leave.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/nice-ligers-leave.md b/.changeset/nice-ligers-leave.md index 66fe2ca..26f31f0 100644 --- a/.changeset/nice-ligers-leave.md +++ b/.changeset/nice-ligers-leave.md @@ -2,4 +2,4 @@ "react-live": patch --- -Fix live preview types. +Fix live preview types. @kyletsang