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
Deprecate .extend in favour of only styled(Component) #1546
Comments
This was how it originally worked, actually—and honestly, I'm not sure it was the right decision to split them. This is the most common confusion for developers, so I think we should move back to the original version and deprecate |
@mxstbr Totally agreed! We've discussed removing it before—and there was some general concensus—so I think it's time to pull the trigger. Shall we deprecate it in the next minor release? |
Let's deprecate and remove from the docs in the next major and make sure we have a codemod in place, then remove the code entirely in the next major after that. |
@mxstbr Do you have any reason to believe that we need to keep it around for another major version? 😅 I think that won't actually make a huge difference |
I don't think folks will be particularly happy about us suddenly throwing warnings in a minor version upgrade. |
Thanks for considering this simplification of the API surface. I agree such removal of API should not happen in a minor update. Please stay true to semver. On the other hand why not release a new major version right away. What to wait for? |
Yeah exactly. |
Yea, I don't have a problem with issuing a major version asap. However, semver doesn't restrict deprecations to major releases. That'd be quite extreme as you'd then during a typical release flow have to release two major bumps—one potentially without breaking changes—just to get new APIs in and remove old ones. Quote:
But anyhow, I'm fine with both, but I'd like to coordinate a new release with #1493 and all related deprecations ( Btw I'll rename the issue to represent the new plan. |
We had a similar convo last year: #1087 I'm definitely in favor of getting rid of |
@probablyup @mxstbr to reiterate a little, I'd wait until both aforementioned PRs are merged and available at which point we can safely deprecate But we could already start a pending PR that adds the deprecation warnings I suppose? |
Sounds perfect |
Reading #1087 I see back then there were strong arguments by members of the project against flattening the API. Good to see decisions can be reverted if they seem to confuse to many users (!) of the library even if the owners initially thought broadening the API surface was a good thing. |
@pke to add some more depth to this prior discussion, what @probablyup was seeing became an increasingly large problem on the implementation side—kudos for seeing this so early btw—and while we preferred the API, over time it became clear that we didn’t even agree ourselves on its practical usage and use cases. Together with having problems with it (component IDs), and having no technical reason for it (specificity correctness is guaranteed, so why concat css?) this is proving to be the way forward. Hope this dimes up everyone’s opinion on the matter :) |
If I am following this correctly, moving forward const Fruit = styled('div')`
color: green;
`;
const Orange = styled(Fruit)`
background: orange;
`; const Fruit = styled('div')`
color: green;
`;
const Orange = Fruit.extend`
background: orange;
`; I'm all for the simplification, however it would be great if the original styles didn't have to be duplicated which is the same issue I have with how |
How would you style a styled component created with const Fruit = styled.div``
const Orange = Fruit.withComponent('span').extend`` Will the following work instead? const Orange = styled(Fruit.withComponent('span')) |
@denkristoffer yes. |
hi, just to add my 2 cents.. I totally agree, this is indeed confusing when starting with styled-components. so i like the idea, as a consumer, not to think about what kind of components I am extending, but here it comes... The documentation stated for a while i think? that |
If |
@ckeeney const A = styled(B).attrs({
style: ({ opacity }) => ({
opacity,
}),
})`
color: red;
` |
That's great news. Thanks, I must have missed that in the docs and thought
it only worked on extend
…On Mon, Apr 16, 2018, 10:05 AM Kristoffer ***@***.***> wrote:
@ckeeney <https://github.com/ckeeney> attrs() works with styled() as it
is:
const A = styled(B).attrs({
style: ({ opacity }) => ({
opacity,
}),
})` color: red;`
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1546 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AIZDIhTDsDYeGMZiwZxqAsWqQ-NNIRc-ks5tpM9cgaJpZM4SPAgL>
.
|
Hey @greypants, could you see the convo here? #1956 If you're using |
@probablyup woaaaaaaah... that pattern is awesome, thanks! So the answer then, is "No"? The Does that mean |
We haven't made a formal decision on it yet, but probably. I'm doing some experimentation to see how difficult it would be to bring the polymorph functionality in as a first class prop API in |
Hello, So the following breaks:
With the component:
|
This is the new syntax for extending components. See: styled-components/styled-components#1546
@RIP21 thanks so much for that codemod! I've moved it to the styled-components organization and packaged it into a single executable for nicer usage: https://github.com/styled-components/styled-components-codemods Will publish a first beta version to npm to try it out 🎉 |
@mxstbr glad to hear! If any issues let me know! :) |
This is the new syntax for extending components. See: styled-components/styled-components#1546
Apologies for posting here but I have tried to search through issues and the change log but would appreciate some clarification. At what version did Obviously in v4 I can see in v3.4.3 that a warning was added when using We are using Thanks! |
AFAIK styled behaves the same way as it did before.
Follow the instructions in codemods repo here in this organization to find
out the tiny difference. Long story short it's dangerous when used in
conjunction with "withComponent" otherwise quite the same behavior.
24 paź 2018 06:54 "Laurie Jones" <notifications@github.com> napisał(a):
Apologies for posting here but I have tried to search through issues and
the change log but would appreciate some clarification.
At what version did styled() get updated to deprecate .extend?
Obviously in v4 .extend is no more and styled() "folds" the functionality
when trying to style a styled component.
I can see in v3.4.3
<https://github.com/styled-components/styled-components/blob/master/CHANGELOG.md#v343---2018-08-21>
that a warning was added when using extend -- does that mean at this point
styled() is handling styling styled-components the way extend used to?
We are using extend in a number of places, in apps with a range of versions
(back to v2) and am unsure about when I can swap out our .extends in our
shared components.
Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1546 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADwe71UEnPV8lVrUEAnYqCJyDGmq1fgjks5un_JugaJpZM4SPAgL>
.
|
Hey @RIP21 Thanks for the quick reply 🙂 I am confused. Surely In my experience using
|
@lauriejones no, the refactor that "folds"/merges styles into each other was only released in v4, although I'm pretty sure your code should still work in v3 if changed to |
I believe I'm running into the same issue that @lauriejones described. After upgrading and moving over to |
use |
The FAQ explains the difference between
styled()
and.extend
. However I wonder if it would be possible to take the decision out of the devs hand and havestyled
check for the handed in Component if its already a styled component. If it is.extend
it otherwise create a new class.Was this considered at one point?
The text was updated successfully, but these errors were encountered: