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

Forward shouldForwardProp through withComponent #1668

Open
wants to merge 2 commits into
base: next
from

Conversation

@animecyc
Copy link

animecyc commented Dec 3, 2019

What:

  • Fixes a bug that prevented shouldForwardProp from forwarding to components created via withComponent; Fixes #1394
  • Compacts createStyled's options argument

Why:

  • Ensures similar composition semantics as the as prop. This sort of begs the question of whether or not the withComponent functionality is needed given we have the as prop; Regardless, they should operate the same if the API exists.

How:

  • Coalesces shouldForwardProp together with options and nextOptions.

Checklist:

  • Documentation
  • Tests
  • Code complete
  • Changeset
@changeset-bot

This comment has been minimized.

Copy link

changeset-bot bot commented Dec 3, 2019

💥 No Changeset

Latest commit: dbdcb09

Merging this PR will not cause any packages to be released. If these changes should not cause updates to packages in this repo, this is fine 🙂

If these changes should be published to npm, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@codecov

This comment has been minimized.

Copy link

codecov bot commented Dec 3, 2019

Codecov Report

Merging #1668 into next will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted Files Coverage Δ
packages/styled/src/base.js 100% <100%> (ø) ⬆️
packages/jest-emotion/src/index.js 100% <0%> (ø) ⬆️
packages/jest-emotion/src/utils.js 96.96% <0%> (+0.06%) ⬆️
@Andarist Andarist changed the base branch from master to next Dec 3, 2019
@Andarist

This comment has been minimized.

Copy link
Member

Andarist commented Dec 3, 2019

Could you branch your change out from the next branch?

@animecyc

This comment has been minimized.

Copy link
Author

animecyc commented Dec 4, 2019

Could you branch your change out from the next branch?

Sure, reconciling things now.

@Andarist

This comment has been minimized.

Copy link
Member

Andarist commented Dec 5, 2019

Not sure exactly why, but the diff includes stuff that it shouldn't. Maybe it would be best to just close this PR and reopen it after branching away from next and cherry-picking your single commit?

@animecyc animecyc force-pushed the animecyc:hotfix/1394 branch from 2f18d6b to 02c5010 Dec 5, 2019
@codesandbox

This comment has been minimized.

Copy link

codesandbox bot commented Dec 5, 2019

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit dbdcb09:

Sandbox Source
Emotion Configuration
@animecyc

This comment has been minimized.

Copy link
Author

animecyc commented Dec 5, 2019

Not sure exactly why, but the diff includes stuff that it shouldn't. Maybe it would be best to just close this PR and reopen it after branching away from next and cherry-picking your single commit?

I thought I pushed, sorry -- its been reconciled now.

? propName =>
nextOptions.shouldForwardProp(propName) &&
defaultShouldForwardProp(propName)
: defaultShouldForwardProp

This comment has been minimized.

Copy link
@animecyc

animecyc Dec 5, 2019

Author

My understanding here is that we want to pipe the shouldForwardProp calls like a funnel (C -> B -> A) using either the supplied shouldForwardProp falling back to the composed defaultShouldForwardProp of the parent.

@animecyc animecyc force-pushed the animecyc:hotfix/1394 branch from 02c5010 to 8b25afa Dec 5, 2019
expect(shouldForwardPropA).toHaveBeenNthCalledWith(1, 'as')
expect(shouldForwardPropA).toHaveBeenNthCalledWith(2, 'disabled')

expect(tree).toMatchSnapshot()

This comment has been minimized.

Copy link
@animecyc

animecyc Dec 5, 2019

Author

I figured it would be good to be a bit more explicit with this test and the calls made to shouldForwardProp on each withComponent

- Fixes a bug that prevented `shouldForwardProp` from forwarding to components created via `withComponent`; Fixes #1394
- Compacts `createStyled`'s options argument
@animecyc animecyc force-pushed the animecyc:hotfix/1394 branch from 8b25afa to 9f88750 Dec 5, 2019
nextTag = { ...nextTag }
nextTag.__emotion_real = nextTag
nextTag.__emotion_styles = nextTag.__emotion_styles.slice(1)
}

This comment has been minimized.

Copy link
@animecyc

animecyc Dec 8, 2019

Author

If we don't remove the prepended label for nextTag we end up with duplicate labels.

Seth Benjamin Seth Benjamin
- Fixes duplicate labels when composing components.
- Allows for correctly setting the label for the new composed component.
@animecyc animecyc force-pushed the animecyc:hotfix/1394 branch from 2508487 to dbdcb09 Dec 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.