variant prop ignored when passed to custom component
See original GitHub issueInput
const MyComponent = ({ children, ...props }) =>
<div {...props}>{children}</div>
const CompWithStyleProp = () =>
<MyComponent color="red">Works: comp with style prop</MyComponent>
const DivWithVariant = () =>
<div variant="heading.h3">Works: div with variant</div>
const CompWithVariant = () =>
<MyComponent variant="heading.h3">Doesn't work: comp with variant</MyComponent>
// render
export default () => (
<div>
<CompWithStyleProp/>
<DivWithVariant/>
<CompWithVariant/>
</div>
)
Output
Expected output
I expect the third line (CompWithVariant
) to be rendered with the heading.h3
variant.
Passing style props to a custom component works as expected.
Passing a variant prop to a regular DOM tag (div
) works as expected.
Passing a variant prop to a custom component does not cause the style to be applied to the rendered output.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Theme UI sx prop ignored when importing a storybook ...
The sx prop isn't passed down to the component, it's in fact converted to CSS and a className is auto-generated and applied to...
Read more >Unknown Prop Warning - React
The unknown-prop warning will fire if you attempt to render a DOM element with a prop that is not recognized by React as...
Read more >Custom props not being passed to react components #1267
The problem Custom props are not being passed to "native" components. React specifies that any lower-case prop will automatically be passed ...
Read more >How to create visual variants for React components using ...
To select a variant of a component you modify the className prop. You can also pass a number of classes this way and...
Read more >The List Component - React-admin - Marmelab
Use the aside prop for that, passing the component of your choice: ... You can also pass React elements as children, to build...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve been able to reproduce this. Looking into it.
Thanks for filing this bug.
Neat, thanks! I will try this out in the next days.