Upgrade to Pro — share decks privately, control downloads, hide ads and more …

10ヶ月かけてstyled-components v4からv5にアップデートした話

uhyo
April 24, 2025

10ヶ月かけてstyled-components v4からv5にアップデートした話

2025-04-24 Qiita Conference 2025

uhyo

April 24, 2025
Tweet

More Decks by uhyo

Other Decks in Technology

Transcript

  1. styled-components React向けCSS in JSの代表的ライブラリのひとつ。 // コード例 const Button = styled.button`

    background: transparent; border-radius: 3px; border: 2px solid #BF4F74; color: #BF4F74; margin: 0 1em; padding: 0.25em 1em; `; 3
  2. 問題のある例 @supports(scrollbar-width: thin) @supports (-webkit-scrollbar-width:thin) or (-moz-scrollbar-width:thin) or (-ms-scrollbar-width:thin) or

    (scrollbar-width:thin) { 14 scrollbar-widthはベンダープレフィクスありとなしで挙動が異なるので ベンダープレフィクス無し版のサポートを検出したかったが、できない
  3. v4→v5の破壊的変更 公式ドキュメントから引用 styled-components v5 does not introduce any breaking public

    API changes, … (訳) styled-components v5ではパブリックAPIに対して破壊的変更はあり ません。… https://styled-components.com/docs/faqs#what-do-i-need-to-do-to-migrate-to-v5 18
  4. 破壊的変更の実際② const ListItem = styled.div` ${({ selected }) => selected

    && css` .dark & { background-color: red; } `} `; 25 v5.2より前: selected: trueなListItemを表す v5.2以降: 全てのListItemを表す