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

merge existing withConfig arguments to allow SSR when using shouldForwardProp #323

Merged
merged 1 commit into from
Jun 29, 2021

Conversation

ithinkdancan
Copy link
Contributor

Resolves issue #322 where if you have an existing withConfig on your component in order to leverage shouldForwardProp babel was not adding a displayName or componentId

this takes the existing expression adds the additional args and replaces the existing withConfig

@ithinkdancan ithinkdancan force-pushed the main branch 2 times, most recently from 07da296 to 2a09ad2 Compare May 1, 2021 20:05
Copy link

@leon-dunamu leon-dunamu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "optional chaining" improves the readability of the code. How about applying this?

@ithinkdancan
Copy link
Contributor Author

ithinkdancan commented May 4, 2021

I think "optional chaining" improves the readability of the code. How about applying this?

@1Seok2 I did not see optional chaining used anywhere else in the code so i instead matched convention with what was there. I assume thats intentional to support versions of node that do not support chaining.

@ithinkdancan
Copy link
Contributor Author

@probablyup can I get a review on this?

@quantizor
Copy link
Collaborator

@ithinkdancan sorry for the delay in reviewing, can you also add a test case for withConfig and attrs being used together?

@ithinkdancan
Copy link
Contributor Author

@probablyup added. works as expected if withConfig is after attrs, seems to have issues if they are swapped and you get 2 withConfigs. could maybe use some ideas on how to remedy that

@quantizor
Copy link
Collaborator

@probablyup added. works as expected if withConfig is after attrs, seems to have issues if they are swapped and you get 2 withConfigs. could maybe use some ideas on how to remedy that

Hmm that won't work, we need it to work in both places or at least before, per the docs:

Keep in mind that, as in this example, other chainable methods should always be executed after .withConfig.

https://styled-components.com/docs/api#shouldforwardprop

@ithinkdancan
Copy link
Contributor Author

ithinkdancan commented May 21, 2021

@probablyup good call out, I have updated the code to be a little smarter about merging the withConfig arguments

Copy link
Collaborator

@quantizor quantizor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TY

@quantizor
Copy link
Collaborator

@ithinkdancan could you merge from main to get the tests running? Just enabled actions for forks. TY!

@ithinkdancan
Copy link
Contributor Author

@probablyup rebased onto main and pushed it up.

@quantizor
Copy link
Collaborator

@probablyup rebased onto main and pushed it up.

Awesome, thank you.

@quantizor quantizor merged commit 6a355b5 into styled-components:main Jun 29, 2021
@quantizor
Copy link
Collaborator

@ithinkdancan waiting on a couple other small PRs and then will cut a release with this in it, thanks for your contribution!

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

Successfully merging this pull request may close these issues.

3 participants