-
Notifications
You must be signed in to change notification settings - Fork 587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix LinkWrapper props to avoid collisions w React, Gatsby, etc links #10
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do this with a one liner, it's kind of mind bending but ultimately better ;)
src/components/Link.js
Outdated
delete linkWrapperProps.inverse; | ||
delete linkWrapperProps.nochrome; | ||
delete linkWrapperProps.secondary; | ||
delete linkWrapperProps.tertiary; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a more idiomatic way to do this is:
const { inverse, nochrome, secondary, tertiary, ...linkWrapperProps } = rest;
return <StyledLinkWrapper {...linkWrapperProps}>{content}</StyledLinkWrapper>;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it. It's funny, I am so used to using that pattern when destructuring in function params, but it felt weird in this context. Makes sense, good eye :)
Updated!
addd86d
to
6191f55
Compare
🚀 PR was released in v0.0.21 🚀 |
I tried to fix this in an earlier PR, but I didn't get it right. I think I have it now -- A lot of the
Link
components that you use w/ other libs like Gatsby & React Router complain when you pass them props that are not standard. I kept seeing errors for this in the console:I decided to just manually delete the props from the prop object that is passed down to the
LinkWrapper
-- that seemed to do the trick.