Skip to content
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

Merged
merged 3 commits into from
Jun 12, 2019

Conversation

kylesuss
Copy link
Contributor

@kylesuss kylesuss commented Jun 6, 2019

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:

Screen Shot 2019-06-06 at 5 38 24 PM

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.

@kylesuss kylesuss requested review from domyen and tmeasday June 6, 2019 23:39
@kylesuss kylesuss changed the title Fix LintWrapper props to avoid collisions w React, Gatsby, etc links Fix LinKWrapper props to avoid collisions w React, Gatsby, etc links Jun 6, 2019
@kylesuss kylesuss changed the title Fix LinKWrapper props to avoid collisions w React, Gatsby, etc links Fix LinkWrapper props to avoid collisions w React, Gatsby, etc links Jun 6, 2019
Copy link
Member

@tmeasday tmeasday left a 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 ;)

delete linkWrapperProps.inverse;
delete linkWrapperProps.nochrome;
delete linkWrapperProps.secondary;
delete linkWrapperProps.tertiary;
Copy link
Member

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>;

Copy link
Contributor Author

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!

@kylesuss kylesuss force-pushed the fix-lint-wrapper-props branch from addd86d to 6191f55 Compare June 7, 2019 03:17
@kylesuss kylesuss requested a review from tmeasday June 7, 2019 13:35
@domyen domyen merged commit 122c5c7 into master Jun 12, 2019
@domyen domyen deleted the fix-lint-wrapper-props branch June 12, 2019 16:33
@kylesuss
Copy link
Contributor Author

🚀 PR was released in v0.0.21 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants