In this detailed (and explanatory) guide, I’ll discuss how to build strongly typed polymorphic React components with TypeScript. We’ll cover the following sections: Real-world examples of polymorphic components Chakra UI’s as prop MUI’s component prop Building a simple polymorphic component Problems with this simple implementation The as prop can receive invalid HTML elements Wrong attributes can
![Build strongly typed polymorphic components with React and TypeScript - LogRocket Blog](https://cdn-ak-scissors.b.st-hatena.com/image/square/aee3c9ec4e1e9dc1ad410080039aeaf6d5c62e60/height=288;version=1;width=512/https%3A%2F%2Fblog.logrocket.com%2Fwp-content%2Fuploads%2F2022%2F05%2Fbuild-strongly-typed-polymorphic-components-with-react-typescript-nocdn.png)