styled-components@6.3.7
Patch Changes
-
51ffa9c: Fix createGlobalStyle compatibility with React StrictMode and RSC
This fix addresses issues where global styles would disappear or behave incorrectly in React StrictMode and RSC:
-
Static styles optimization: Static global styles (without props/interpolations) are now only injected once and won't be removed/re-added on every render. This prevents the style flickering that could occur during concurrent rendering.
-
StrictMode-aware cleanup: Style cleanup now uses
queueMicrotaskto coordinate with React's effect lifecycle. In StrictMode's simulated unmount/remount cycle, styles are preserved. On real unmount, styles are properly removed. -
RSC compatibility: Move
useRefinside RSC guard increateGlobalStyleand unify alluseContextcalls to use consistent!IS_RSC ?pattern. -
RSC inline style tag cleanup: Fix bug where server-defined
createGlobalStylerendered in client components would leave behind accumulated SSR-rendered inline tags. The cleanup effect now removes these hoisted style tags when the component unmounts or re-renders with different CSS.
-