Polymorphic Component Element Attributes
Explore no attribute support for the basic polymorphic component implementations.
We'll cover the following...
Introduction
Let's consider the current simple implementation again:
import React from "react";export const PolymorphicText = ({ as, children }) => {const Component = as || "span";return <Component>{children}</Component>;};
The only props this component accepts are as and children, and nothing else.
const PolymorphicText = ({ as, children }) => {...};
There’s no attribute support taken into consideration here. For example, if as were the anchor element a, a consumer should also ...