File tree Expand file tree Collapse file tree
packages/react-live/src/components/Live Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " react-live " : patch
3+ ---
4+
5+ Fix live preview types. @kyletsang
Original file line number Diff line number Diff line change 1- import React , { PropsWithChildren , useContext } from "react" ;
1+ import React , { useContext } from "react" ;
22import LiveContext from "./LiveContext" ;
33
4- type Props = {
5- Component ?: React . ComponentType < PropsWithChildren < Record < string , unknown > > > ;
6- } ;
4+ type Props < T extends React . ElementType = React . ElementType > = {
5+ Component ?: T ;
6+ } & React . ComponentPropsWithoutRef < T > ;
77
8- const fallbackComponent = (
9- props : PropsWithChildren < Record < string , unknown > >
10- ) => < div { ...props } /> ;
8+ function LivePreview < T extends keyof JSX . IntrinsicElements > (
9+ props : Props < T >
10+ ) : JSX . Element ;
11+ function LivePreview < T extends React . ElementType > ( props : Props < T > ) : JSX . Element ;
1112
12- function LivePreview ( { Component = fallbackComponent , ...rest } : Props ) {
13+ function LivePreview ( { Component = "div" , ...rest } : Props ) : JSX . Element {
1314 const { element : Element } = useContext ( LiveContext ) ;
1415 return < Component { ...rest } > { Element ? < Element /> : null } </ Component > ;
1516}
You can’t perform that action at this time.
0 commit comments