styled-components v5.0.1 Release Notes

Release Date: 2020-02-04 // 14 days ago

    ➕ Added useTheme hook to named exports for react native (#2982)

    🐎 Performance enhancements

    • Refactored hashing function that is a bit faster in benchmarks (#2983)

    - Fixed a bitwise math issue that was causing SSR performance degradations due to how we allocate typed arrays under the hood (#2996)

    ➕ Added some helpful new dev-time warnings for antipatterns

    • Recommending against usage of css @import inside createGlobalStyle and what to do instead (#2997)
    • Catching and warning against dynamic creation of styled-components inside other component render paths (#2998)

Previous changes from v5.0.0

  • 🚀 Read the v5 release announcement!

    • 19% smaller bundle size
    • 18% faster client-side mounting
    • 💅 17% faster updating of dynamic styles
    • 45% faster server-side rendering
    • 👍 RTL support

    💅 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.

    • 💅 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>
    • Remove deprecated attrs "subfunction" syntax variant

      styled.div.attrs({ color: p => p.color });

    should become

      styled.div.attrs(p => ({ color: p.color }));

    You can still pass objects to attrs but individual properties shouldn't have functions that receive props anymore.

    • 🛠 Fix attrs not taking precedence over props when overriding a given prop

    • 🚀 (ReactNative) upgrade css-to-react-native to v3 (changelog)

      • Removed support for unitless line height in font shorthand
    • 💅 Replace merge-anything with mixin-deep to save some bytes (this is what handles merging of defaultProps between folded styled components); this is inlined into since the library is written in IE-incompatible syntax

    • 🛠 Fix certain adblockers messing up styling by purposefully not emitting the substring "ad" (case-insensitive) when generating dynamic class names

    • 🛠 Fix regressed behavior between v3 and v4 where className was not correctly aggregated between folded .attrs invocations