v5.0.0
It's finally here!!! 馃殌See the migrating to v5 FAQ page for easy upgrade instructions!
Read the v5 release announcement!
TL;DR:
- 19% smaller bundle size
- 18% faster client-side mounting
- 17% faster updating of dynamic styles
- 45% faster server-side rendering
- RTL support
...and much more all, with no breaking changes!
NOTE: At this time we recommend not using @import
inside of createGlobalStyle
. We're working on better behavior for this functionality but it just doesn't really work at the moment and it's better if you just embed these imports in your HTML index file, etc.
Changes
-
StyleSheetManager
enhancements- you can now supply stylis plugins like stylis-plugin-rtl;
<StyleSheetManager stylisPlugins={[]}>...</StyleSheetManager>
disableVendorPrefixes
removes autoprefixing if you don't need legacy browser support;<StyleSheetManager disableVendorPrefixes>...</StyleSheetManager>
disableCSSOMInjection
forces using the slower injection mode if other integrations in your runtime environment can't parse CSSOM-injected styles;<StyleSheetManager disableCSSOMInjection>...</StyleSheetManager>
- you can now supply stylis plugins like stylis-plugin-rtl;
-
Removed the "subfunction" attrs syntax that was deprecated in v4
styled.div.attrs({ role: p => p.onClick ? 'button' : '' })` color: red; `
becomes
styled.div.attrs(p => ({ role: p.onClick ? 'button' : '' }))` color: red; `
-
Update css-to-react-native to v3.0.0 (#2811); the one breaking change noted is that unitless line height is no longer allowed when setting font properties
- if you get a lot of warnings at dev time from not having units in your styles, this codemod is available to help expedite updates: https://github.com/styled-components/styled-components-native-code-mod thanks @jacobp100
-
disallow /ad/i in generated class names (#2837); this change primarily helps to avoid some overly aggressive ad blockers that will mangle generated classnames containing the substring "ad"
-
if you use styled-components from CDN, in v5 the "react-is" dependency was added (make sure you add this to your project)