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

feat: pass elementToBeCreated to shouldForwardProp #3436

Merged

Conversation

agriffis
Copy link
Contributor

Currently it's not possible to replicate styled-components' internal logic in shouldForwardProp, because it doesn't have all the information. It only gets the prop key, not elementToBeCreated, and so it can't properly decide in a generic manner whether to forward props.

This PR upgrades shouldForwardProp to include elementToBeCreated as a third parameter. This should be backward-compatible with existing code because it only passed two parameters previously.

This is especially for when a styled component is called with as, because that makes the decision of whether to forward props more dynamic than is currently possible to express.

This PR should probably also update some documentation somewhere. I can make an additional commit if it otherwise looks good to y'all.

@quantizor
Copy link
Contributor

Makes sense to me, can you add a changelog entry?

The internal decision whether to forward a prop is based on the
combination of the key and elementToBeCreated, but only the former was
passed to shouldForwardProp.
@agriffis agriffis force-pushed the feat/shouldForwardProp-element branch from 67045e4 to 6021916 Compare March 30, 2021 17:46
@agriffis
Copy link
Contributor Author

@probablyup I just force-pushed with the changelog entry.

I actually replaced the babel macro changelog entry which doesn't need to be duplicated between 5.2.2 and the unreleased section.

@quantizor quantizor merged commit 95c7a81 into styled-components:master Mar 31, 2021
agriffis added a commit to agriffis/styled-components that referenced this pull request Apr 2, 2021
The internal decision whether to forward a prop is based on the
combination of the key and elementToBeCreated, but only the former was
passed to shouldForwardProp.

This is a port of styled-components#3436 to legacy-v5
agriffis added a commit to agriffis/styled-components that referenced this pull request Apr 2, 2021
The internal decision whether to forward a prop is based on the
combination of the key and elementToBeCreated, but only the former was
passed to shouldForwardProp.

This is a port of styled-components#3436 to legacy-v5
quantizor pushed a commit that referenced this pull request Apr 6, 2021
The internal decision whether to forward a prop is based on the
combination of the key and elementToBeCreated, but only the former was
passed to shouldForwardProp.

This is a port of #3436 to legacy-v5
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.

None yet

2 participants