FormidableLabs / nextjs-sanity-fe

NextJS Demo site with Sanity CMS
https://nextjs-sanity.formidable.dev/
29 stars 6 forks source link

refactor: polymorphic component #211

Closed nlkluth closed 10 months ago

nlkluth commented 10 months ago

What

Adds Polymorphic types for components

Why

To be more generic, allowing as prop for rendering.

Example

Turn a component that renders a button into a link with as="a". All of the HTMLAnchorElement types now show and are allowed. Screenshot 2023-11-09 at 10 45 26 AM

See also

  1. https://www.benmvp.com/blog/polymorphic-react-components-typescript/
  2. https://www.benmvp.com/blog/forwarding-refs-polymorphic-react-component-typescript/
vercel[bot] commented 10 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextjs-sanity-fe ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 9, 2023 7:39pm