Sanity 拯救了垂死的 styled-components:性能提升 40%

2025-09-12
Sanity 拯救了垂死的 styled-components:性能提升 40%

流行的 CSS-in-JS 库 styled-components 进入维护模式后,Sanity 公司出手相助,通过修复和优化,发布了两个分支版本,分别兼容 React 18 和 React 19。这两个版本利用 React 18 的 useInsertionEffect hook 和 React 19 的内联样式特性,显著提升了性能,在某些情况下渲染速度提升高达 40%。文章详细介绍了修复过程和性能提升的细节,并为使用 styled-components 的开发者提供了分阶段迁移方案,帮助开发者在迁移到其他 CSS 方案之前,先提升应用性能。