MathiasGilson / Tailwind-Styled-Component

Create Tailwind CSS React components like styled components with class names on multiple lines and conditional class rendering
MIT License
818 stars 43 forks source link

Polymorphic with svg? #98

Closed mhpaler closed 1 year ago

mhpaler commented 1 year ago

would like to do something like this:

import OutlinkSVG from "@app/assets/Outlink.svg";
const OutlinkIcon = tw.div`p-2`;

<OutlinkIcon $as={OutlinkSVG} />

But react complains with:

Unhandled Runtime Error
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

Check the render method of `tw.div`.

Any ideas?

mhpaler commented 1 year ago

Ugh. nevermind, just didn't have @svgr/webpack and webpack configured for svgs as components.