kripod / react-polymorphic-types

Zero-runtime polymorphic component definitions for React
MIT License
195 stars 8 forks source link

React.forwardRef example #2

Closed tu4mo closed 3 years ago

tu4mo commented 3 years ago

I'm trying to figure out the example for forwardRef'd component.

kripod commented 3 years ago

Thanks for your feedback!

HeadingProps are exported as an example to follow conventions set by libraries. Each component’s corresponding prop types are made available alongside the component itself, e.g.:

import { Heading, HeadingProps } from "@/components/Heading";

React.ForwardedRef is available in a separate @react/types package (which is marked as a peer dependency).

tu4mo commented 3 years ago

Oh, I had types for React 16 installed. Thanks!