-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[Core] remove style-propable mixin from components #2852
Comments
@yongxu The long term plan is to remove all the mixins, and work on removing style-propable has already started for some of the components. For example, style-propable has been replaced with style utils in |
@alitaheri I know 😄 Just figured it'd be nice to track in this Github issue as well, as since @yongxu opened this, might be nice to see at the top of the issue. |
Ohhh you mean a checklist we can track the progress of. I like that idea, yeah that sounds very good 👍 👍 👍 |
yeah sure thing @newoga here are the components that currently using style-propable Edit: Place at the top |
there are so many of them, but it is actually very easy to track, just search |
Thanks for the change @alitaheri ! Really like the check list :) |
Thank you. Now we can track the progress 😁 😁 |
@yongxu @alitaheri Perfect, thanks much! (Those are a lot 😨). I'll make sure to mark my progress here as I remove uses of the mixin. Based on my memory, this mixin was going to be one of the easier ones to remove. |
Today I was thinking about the best ways to replace Plus, AutoPrefix is very costly. IMO, We should manually adding default style prefix and leave the user to decide if they'd like to use AutoPrefixer themselves. Currently, in mergeStyles() {
return ImmutabilityHelper.merge.apply(this, arguments);
} that in immutability-helper, import update from 'react-addons-update';
function mergeSingle(objA, objB) {
if (!objA) return objB;
if (!objB) return objA;
return update(objA, {$merge: objB});
}
//here is the merge called
merge() {
const args = Array.prototype.slice.call(arguments, 0);
let base = args[0];
for (let i = 1; i < args.length; i++) {
if (args[i]) {
base = mergeSingle(base, args[i]);
}
}
return base;
}, In most cases, this is totally waste of time.
is simply equivalent to
The two other functions
Those two functions are highly used in React render function. I think this might slow down the response time x10~ times. No testing, just my estimate. There is a quite shocking result I found: In practice, it is not complicated to manage AutoPrefix or left-to-right direction. We should remove these from the library. @alitaheri @newoga @oliviertassinari |
@yongxu I agree that ideally these should be removed entirely. Right now there are discussions about using another library/tool/approach for styling and I think any significant work in this area will probably have to wait until we make that decision. I haven't fully considered the short term implications of not using those methods in existing components, but I can't imagine it not being a breaking change. I think we should carefully consider all alternatives before making this switch and try to get it right the first time.
I would like to give users more flexibility in this process, but do you have an ideas how this could work? |
@yongxu I couldn't agree more even if I wanted to! We have a plan for these. first and most importantly we should remove a huge number of lines of code in 0.15.0 so we can move more freely, right now too many things are deprecated. and having them around really ties our hands behind our backs. With those codes removed we can do a whole lot of things. one of them would be memoization of calculated styles, optimization of these functions, using better libraries like Radium and Recompose and a whole lof of things. but with all these old rusty codes around it's really hard. |
@newoga IMO, manually adding prefix is more efficient. The idea is actually very simple:
can be rewritten as:
So we can simply write
as
@alitaheri Yeah I totally agree with you. IMO, If we are going to remove style-propable, the mixin that deals with style merge, we should write the whole mechanism to make it as efficient as possible. If we simply replace them with the current helper function there won't be much performance improvement and we probably have to rewrite this part again in the future. It is probably the best time to redesign the style merge and resolve this issue once for all. Radium is a good library, but also slow. For many basic components such as buttons or text fields, manually adding prefix is the most performance efficient. It is worth to put a little extra time since one site may contain hundreds of these elementary blocks. |
I think the slowness is negligible if it happens only once. I mean with memoization we shouldn't worry so much about prefixing. But with manual prefixing there will be many things to worry about, things like maintenance, more things to teach contributes, much harder code review, etc, etc... . I'm always against doing things that external libraries can do better much better myself. @oliviertassinari @newoga Thoughts? |
@alitaheri Manual prefixing everything is indeed quite a lot work and much harder code review. I totally agree with you on this. However, memoization may cause internal state. I think the 20-80 rule is probably a good choice here, focus on prefixing the low level components such as Paper, and keeping code clarity for some not so frequently used components like DatePicker. Paper is probably the most used component, but if you take a look at its render function, there is definitely quite a bit problem here:
|
There is also server-side-rendering. without user-agent aware prefixing we'll end up with tons of useless prefixed going down the wire. surely a very new browser will never need any prefix. we'll have to add a huge number of bytes only to supper a very few number of target browsers. Such things can be very easily handled by libraries. Surely they are slow, but we don't need that much performance if we handle the flow right. (with memoization)
Why do you say that? I can't imagine how memoization can do this if we handle things right. Also handling memoization right is A LOT easier than handling prefixing right. I for one know exactly how to memoize with ease and determinism. But I truly suck at prefixing 😢 😢 Just a side note. I mean absolutely no offense. you points are valid. And I really enjoy brainstorming 😁 Thank you for taking the time to discuss this in the first place, 👍 👍 |
That's also related to #2437. |
@yongxu @alitaheri @oliviertassinari I have a suggestion that basically sums what was presented in this issue and proposes a next step forward. 😄 1. Replace style-propable mixin with utility functionsI think we would all agree that these functions do not need to be in a mixin. We have an exported utility library at The 2. Finalize how we should change and use
|
Great sum up @newoga 👍 👍 I agree on all fronts 😁 Thank you |
I'd love to see more ideas and different opinions. No worries your point is not offencive at all. I'd like to see all different opinions even if they are offencive, as long as they are valid. 👍 @oliviertassinari
Your are right on this, sorry I did not see this line I also tried to run few components using chrome timeline. The cost were probably not as high as I expected initially, they are still quite costly and should be optimized. Not very familiar with chrome timeline, but I think the point is still valid. |
Babel transpile var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; It would be intereseting to see the performance differences between
The thing is, I can't see how users can deal with RTL on their side. |
@oliviertassinari merge uses react-addons-update, performance wise it is surely slower and makes code more complicated. There is no reason to import an addon if it is not necessary. RTL can be dealt by rewriting style, maybe we can put this part of code into theme manager. Checking each style element in every rendering is just too much overhead and not very reasonable. |
[Menus] Remove style-propable mixin
[Avatar] Remove style-propable mixin
[LeftNav] Remove style-propable mixin
[Tabs] Remove style-propable mixin
[Progress] Remove style propable mixin
[Card] Remove style-propable mixin
[FAB] Remove style-propable mixin
[Snackbar] Remove style-propable mixin
[List] Remove style-propable mixin
[EnhancedButton] Remove style-propable mixin
[SelectField] Remove style-propable mixin
[EnhancedTextArea] Remove style-propable mixin
[InkBar] Remove style-propable mixin
[RaisedButton] Remove style-propable mixin
[SelectableEnhance] Remove style-propable mixin
[DatePicker] Remove style-propable mixin
[EnhancedSwitch] Remove style-propable mixin
[TextField] Remove style-propable mixin
That's pretty awesome 🚀. @newoga Good job! |
[Core] Deprecate style-propable mixin
Sorry to comment on a closed ticket, but it seems previous devs on our app used the internal material-ui versions of style-propable mixin in our own code, and now that material-ui has removed it, our code now breaks and I need to figure out how to remove the coupling in our code. Any suggestions? |
@bytor99999 I'm sorry to hear that. There are a handful approaches to tackling a migration like this and it probably all depends on how large your codebase is, how coupled you are to the mixin (including which methods you are using), and how much manual effort you are willing to invest. The old mixin implementation is here: https://github.com/callemall/material-ui/blob/v0.14.4/src/mixins/style-propable.js You could probably reimplement the mixin in your local project and change all the import paths from material-ui to your new local module. That would probably be the least impact on your current code, however that being said, your larger goal should probably be to move away from mixins entirely as the React community is moving away from it. To see how this project moved away from the mixin, you can look at any of our closed PRs that show how we did it for each component: https://github.com/callemall/material-ui/pulls?q=is%3Apr+style-propable+is%3Aclosed. Rather than blindly following the same approach we took, you may want to consider changing your code to not use material-ui at all for If you have a really large codebase, my feedback would be to:
Good luck! Edit: The original comment to this issue has a links to each PR where the mixin was removed. |
style-propable is a mixin that I really don't see why it should exist. This mixin does not affect component's life cycle and the only thing it does is inject helper functions.
This mixin appears in most of the components and is the only mixin in most cases. Removing this not only improves the performance and clarity, more importantly, many components will be changed to
pure
and written in es6 style.List of components:
material-ui\src\app-bar.jsx
([AppBar] Remove style-propable mixin #3183)material-ui\src\app-canvas.jsx
([AppCanvas] Remove style-propable mixin #3184)material-ui\src\auto-complete.jsx
([AutoComplete] Remove style-propable mixin #3350)material-ui\src\avatar.jsx
([Avatar] Remove style-propable mixin #3235)material-ui\src\badge.jsx
([Badge] Remove style-propable mixin #3185)material-ui\src\before-after-wrapper.jsx
([BeforeAfterWrapper] Remove style-propable mixin #3228)material-ui\src\buttons\flat-button-label.jsx
([Button] Remove style-propable mixin from flat-button-label #3197)material-ui\src\card\card-actions.jsx
([Card] Remove style-propable mixin #3198)material-ui\src\card\card-expandable.jsx
([Card] Remove style-propable mixin #3198)material-ui\src\card\card-header.jsx
([Card] Remove style-propable mixin #3198)material-ui\src\card\card-media.jsx
([Card] Remove style-propable mixin #3198)material-ui\src\card\card-text.jsx
([Card] Remove style-propable mixin #3198)material-ui\src\card\card-title.jsx
([Card] Remove style-propable mixin #3198)material-ui\src\card\card.jsx
([Card] Remove style-propable mixin #3198)material-ui\src\checkbox.jsx
([Checkbox] Remove style-propable mixin #3234)material-ui\src\circular-progress.jsx
([Progress] Remove style propable mixin #3233)material-ui\src\date-picker\calendar-year.jsx
([DatePicker] Remove style-propable mixin #3291)material-ui\src\date-picker\calendar.jsx
([DatePicker] Remove style-propable mixin #3291)material-ui\src\date-picker\date-display.jsx
([DatePicker] Remove style-propable mixin #3291)material-ui\src\date-picker\date-picker-dialog.jsx
([DatePicker] Remove style-propable mixin #3291)material-ui\src\date-picker\date-picker.jsx
([DatePicker] Remove style-propable mixin #3291)material-ui\src\date-picker\day-button.jsx
([DatePicker] Remove style-propable mixin #3291)material-ui\src\date-picker\year-button.jsx
([DatePicker] Remove style-propable mixin #3291)material-ui\src\dialog.jsx
([Dialog] Remove style-propable mixin #3218)material-ui\src\drop-down-icon.jsx(removed in [Core] Remove the deprecated API of v0.14.x #3108)material-ui\src\enhanced-button.jsx
([EnhancedButton] Remove style-propable mixin #3254)material-ui\src\enhanced-switch.jsx
([EnhancedSwitch] Remove style-propable mixin #3255)material-ui\src\enhanced-textarea.jsx
([EnhancedTextArea] Remove style-propable mixin #3252)material-ui\src\floating-action-button.jsx
([FAB] Remove style-propable mixin #3251)material-ui\src\font-icon.jsx
([FontIcon] Remove style-propable mixin #3230)material-ui\src\grid-list\grid-list.jsx
([GridList] Remove style-propable mixin #3202)material-ui\src\grid-list\grid-tile.jsx
([GridList] Remove style-propable mixin #3202)material-ui\src\hoc\selectable-enhance.js
([SelectableEnhance] Remove style-propable mixin #3261)material-ui\src\icon-button.jsx
([IconButton] Remove style-propable mixin #3232)material-ui\src\ink-bar.jsx
([InkBar] Remove style-propable mixin #3256)material-ui\src\left-nav.jsx
([LeftNav] Remove style-propable mixin #3229)material-ui\src\linear-progress.jsx
([Progress] Remove style propable mixin #3233)material-ui\src\lists\list-item.jsx
([List] Remove style-propable mixin #3259)material-ui\src\lists\list.jsx
([List] Remove style-propable mixin #3259)material-ui\src\menu\link-menu-item.jsx(removed in [Core] Remove the deprecated API of v0.14.x #3108)material-ui\src\menu\menu-item.jsx(removed in [Core] Remove the deprecated API of v0.14.x #3108)material-ui\src\menu\menu.jsx(removed in [Core] Remove the deprecated API of v0.14.x #3108)material-ui\src\menu\subheader-menu-item.jsx(removed in [Core] Remove the deprecated API of v0.14.x #3108)material-ui\src\menus\icon-menu.jsx
([Menus] Remove style-propable mixin #3219)material-ui\src\menus\menu-item.jsx
([Menus] Remove style-propable mixin #3219)material-ui\src\menus\menu.jsx
([Menus] Remove style-propable mixin #3219)material-ui\src\overlay.jsx
([Overlay] Remove style-propable mixin #3220)material-ui\src\paper.jsx
([Paper] Remove style-propable mixin #3221)material-ui\src\popover\popover-animation-from-top.jsx
([Popover] Remove style-propable mixin #3201)material-ui\src\popover\popover-default-animation.jsx
([Popover] Remove style-propable mixin #3201)material-ui\src\popover\popover.jsx
([Popover] Remove style-propable mixin #3201)material-ui\src\radio-button-group.jsx
([RadioButton] Remove style-propable mixin #3224)material-ui\src\radio-button.jsx
([RadioButton] Remove style-propable mixin #3224)material-ui\src\raised-button.jsx
([RaisedButton] Remove style-propable mixin #3263)material-ui\src\refresh-indicator.jsx
([Progress] Remove style propable mixin #3233)material-ui\src\ripples\circle-ripple.jsx
([Ripple] Remove style-propable mixin #3199)material-ui\src\ripples\focus-ripple.jsx
([Ripple] Remove style-propable mixin #3199)material-ui\src\ripples\touch-ripple.jsx
([Ripple] Remove style-propable mixin #3199)material-ui\src\SelectField\SelectField.jsx
([SelectField] Remove style-propable mixin #3260)material-ui\src\slider.jsx
material-ui\src\snackbar.jsx
([Snackbar] Remove style-propable mixin #3257)material-ui\src\svg-icon.jsx
([SvgIcon] Remove style-propable mixin #3222)material-ui\src\table\table-body.jsx
([Table] Remove style-propable mixin #3227)material-ui\src\table\table-footer.jsx
([Table] Remove style-propable mixin #3227)material-ui\src\table\table-header-column.jsx
([Table] Remove style-propable mixin #3227)material-ui\src\table\table-header.jsx
([Table] Remove style-propable mixin #3227)material-ui\src\table\table-row-column.jsx
([Table] Remove style-propable mixin #3227)material-ui\src\table\table-row.jsx
([Table] Remove style-propable mixin #3227)material-ui\src\table\table.jsx
([Table] Remove style-propable mixin #3227)material-ui\src\tabs\tab.jsx
([Tabs] Remove style-propable mixin #3236)material-ui\src\tabs\tabs.jsx
([Tabs] Remove style-propable mixin #3236)material-ui\src\TextField\TextField.jsx
([TextField] Remove style-propable mixin #3349)material-ui\src\time-picker\clock-hours.jsx
([TimePicker] Remove style-propable mixin #3188)material-ui\src\time-picker\clock-minutes.jsx
([TimePicker] Remove style-propable mixin #3188)material-ui\src\time-picker\clock-number.jsx
([TimePicker] Remove style-propable mixin #3188)material-ui\src\time-picker\clock-pointer.jsx
([TimePicker] Remove style-propable mixin #3188)material-ui\src\time-picker\clock.jsx
([TimePicker] Remove style-propable mixin #3188)material-ui\src\time-picker\time-display.jsx
([TimePicker] Remove style-propable mixin #3188)material-ui\src\time-picker\time-picker-dialog.jsx
([TimePicker] Remove style-propable mixin #3188)material-ui\src\time-picker\time-picker.jsx
([TimePicker] Remove style-propable mixin #3188)material-ui\src\toggle.jsx
([Toggle] Remove style-propable mixin #3189)material-ui\src\toolbar\toolbar-group.jsx
([Toolbar] Remove style-propable mixin #3180)material-ui\src\toolbar\toolbar-separator.jsx
([Toolbar] Remove style-propable mixin #3180)material-ui\src\toolbar\toolbar-title.jsx
([Toolbar] Remove style-propable mixin #3180)material-ui\src\toolbar\toolbar.jsx
([Toolbar] Remove style-propable mixin #3180)material-ui\src\tooltip.jsx
([Tooltip] Remove style-propable mixin #3203)material-ui\src\transition-groups\scale-in-child.jsx
([Core] Remove style-propable mixin from transition-groups #2909)material-ui\src\transition-groups\scale-in.jsx
([Core] Remove style-propable mixin from transition-groups #2909)material-ui\src\transition-groups\slide-in-child.jsx
([Core] Remove style-propable mixin from transition-groups #2909)material-ui\src\transition-groups\slide-in.jsx
([Core] Remove style-propable mixin from transition-groups #2909)The text was updated successfully, but these errors were encountered: