-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Warn when using overlapping styles (e.g. border and borderBottom) #6348
Comments
@gaearon Thank you for resurfacing this! Crazy that it has been a year since I opened the Radium issue. I like the idea of warning about shorthand properties like Question. Is the intent of this issue to address only the analysis of individual style objects or is there also a desire to analyze and warn about possible collisions of properties that are conditionally applied? |
Not sure I understand the question, can you elaborate? |
Sure. If it is invalid to have both |
Ah, good point. I’d probably warn only if we know the styles overlap but I’m not sure how easy it is to tell. I haven’t thought about it much and I don’t have a good solution. |
What about situations where a third-party component defines styles and allows overrides? Say a component defines its own |
I've started working on dead-simple helper functions to convert shorthand properties to longform (among other things): https://github.com/rtsao/lostyle/tree/master/src (docs) |
- Prevent using style conflicting properties like border and border Button facebook/react#6348 - Avoid using ES6 features that can't be transpiled like includes - Remove dead style properties
This is super unpredictable and confusing and I just ran into this. I'd suggest we at least warn on updates when we know it's problematic? That is, if we go from {background: a, backgroundSize: b} to {background: c, backgroundSize: b}, warn that backgroundSize is being overridden (but if backgroundSize changes at the same time, don't warn). We can do this for all property shorthands and know whether it's problematic from the property enumeration order. |
Marking as "good first issue". Let's add a DEV-only warning for this per my comment above. I think a good place to begin investigating would be here: If you'd like to take this on, please comment here so that we don't have two people working on this. |
@sophiebits, I am happy to work on this one :) |
@supertinou It's yours! |
Just hit this and was indeed surprised and confused by it. |
@supertinou Just wanted to check if there's anything I can help you with on this. |
@sophiebits Hi I don't want to step on anybodies toes :D but I've taken a look into this issue, replicated it and would love to take a stab at it but I don't know if @supertinou is still working on it. |
I made a codepen to recap/explain what is going on https://codepen.io/giuseppegurgone/pen/mjKbmq?editors=0010 @gaearon / @sophiebits let me know if I forgot something. |
@mirkojotic Still interested? |
If there is no one i would like to take this one :) |
All right @YongPilMoon, it's yours. |
Adding a note here: removing a property can also trigger this bug. https://stackoverflow.com/q/52636618/49485 |
This is one of the most insidious quirks of React DOM that people run into. Now we warn when we think an update is dangerous. We still allow rendering `{background, backgroundSize}` with unchanging values, for example. But once you remove either one or change `background` (without changing `backgroundSize` at the same time), that's bad news. So we warn. Fixes facebook#6348.
This is one of the most insidious quirks of React DOM that people run into. Now we warn when we think an update is dangerous. We still allow rendering `{background, backgroundSize}` with unchanging values, for example. But once you remove either one or change `background` (without changing `backgroundSize` at the same time), that's bad news. So we warn. Fixes facebook#6348.
This is one of the most insidious quirks of React DOM that people run into. Now we warn when we think an update is dangerous. We still allow rendering `{background, backgroundSize}` with unchanging values, for example. But once you remove either one or change `background` (without changing `backgroundSize` at the same time), that's bad news. So we warn. Fixes #6348.
This is one of the most insidious quirks of React DOM that people run into. Now we warn when we think an update is dangerous. We still allow rendering `{background, backgroundSize}` with unchanging values, for example. But once you remove either one or change `background` (without changing `backgroundSize` at the same time), that's bad news. So we warn. Fixes facebook#6348.
This is one of the most insidious quirks of React DOM that people run into. Now we warn when we think an update is dangerous. We still allow rendering `{background, backgroundSize}` with unchanging values, for example. But once you remove either one or change `background` (without changing `backgroundSize` at the same time), that's bad news. So we warn. Fixes facebook#6348.
The warning is out in 16.13. |
- Prevent using style conflicting properties like border and border Button facebook/react#6348 - Avoid using ES6 features that can't be transpiled like includes - Remove dead style properties
This "good first bug" is taken by @YongPilMoon. Don't work on it unless that's you!
This has been discussed a few times before but I don’t think there was any conclusion, and PRs intending to solve the issue were not merged for various reasons.
I would like to close those PRs as outdated, and reboot the discussion about this.
Performance considered, the conclusion from @sebmarkbage and @syranide seems to be:
— #2013 (comment)
— #4661 (comment)
Radium by @ianobermiller came to the same conclusion in FormidableLabs/radium#95 but there was some backlash afterwards. React Native seems to allow style expansions but only for a few attributes (e.g.
margin
andpadding
, but notborder
).I’m closing old pull requests about this, and creating this issue to track implementation of the behavior we seem to agree upon: we should warn in
__DEV__
whenborder
andborderBottom
are used at the same time. We can discuss more specifics (should either be ignored? should we allow a few whitelisted properties but warn for others?) in this issue.As a migration strategy, we can suggest people to use something like https://github.com/ActionIQ/style-builder if they really need those shortcuts. It’s also something we’ll need to decide upon when implementing integrated styling.
Related issues:
backgroundSize
property lost when re-rendering an image URL inside of an adjacentbackground
property #5030Related PRs:
The text was updated successfully, but these errors were encountered: