Passing props to custom element like Link #458
Answered
by
ben-rogerson
yudyananda
asked this question in
Q&A
-
Hi, i wonder how to passing props to custom component properly. In my case is Link component from gatsby // style.js
import { Link } from 'gatsby'
const MyLink = styled(Link)`
${({ fooBar }) => (fooBar ? tw`inline-flex` : tw`block`)}
`;
//Component.js
<MyLink to="/" fooBar={fooBar}>
{baz}
</MyLink> then the console show the following error
|
Beta Was this translation helpful? Give feedback.
Answered by
ben-rogerson
Jun 15, 2021
Replies: 1 comment 1 reply
-
I use emotion's shouldForwardProp to make sure the prop doesn't get passed down to the element, making sure it's only used for styling. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
yudyananda
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use emotion's shouldForwardProp to make sure the prop doesn't get passed down to the element, making sure it's only used for styling.