From 60f767207cab2d3394c74d64c6cf8bfbad8185fe Mon Sep 17 00:00:00 2001 From: Nuey San Waldman Date: Tue, 5 Dec 2023 11:23:45 +0100 Subject: [PATCH] Update example to use ReactNode over ReactElement --- .../PolymorphicComponentProps.mdx | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/types/PolymorphicComponentProps/PolymorphicComponentProps.mdx b/src/types/PolymorphicComponentProps/PolymorphicComponentProps.mdx index 1d1d27e..d51ab55 100644 --- a/src/types/PolymorphicComponentProps/PolymorphicComponentProps.mdx +++ b/src/types/PolymorphicComponentProps/PolymorphicComponentProps.mdx @@ -19,7 +19,7 @@ type FooComponentProps = PolymorphicComponentProps< { barProp: string | undefined } >; -type FooComponent = (props: FooComponentProps) => ReactElement | null; +type FooComponent = (props: FooComponentProps) => ReactNode | null; export const Foo: FooComponent = ({ as: Component = 'div', @@ -68,16 +68,18 @@ type FooComponentProps = PolymorphicComponentPropsWithRef { barProp: string | undefined } >; -type FooComponent = (props: FooComponentProps) => ReactElement | null; - -export const Foo: FooComponent = ( - { as: Component = 'div', children, ...otherProps }: FooComponentProps, - ref?: PolymorphicRef, -) => { - return ( - - {children} - - ); -}; +type FooComponent = (props: FooComponentProps) => ReactNode | null; + +export const Foo: FooComponent = forwardRef( + ( + { as: Component = 'div', children, ...otherProps }: FooComponentProps, + ref?: PolymorphicRef, + ) => { + return ( + + {children} + + ); + }, +); ```