Releases: styled-components/styled-components
[email protected]
Patch Changes
- 752f5ec: fix: resolve "React is not defined" ReferenceError introduced in 6.3.10 when loading the CJS build in Node.js
[email protected]
Patch Changes
-
f674224: fix: RSC style tags for extended components have correct href and include base CSS (#5663)
- Fix spaces in
<style href>attribute that caused React 19 hydration failures when usingstyled()inheritance - Fix missing base component CSS in RSC output when only the extended component renders
- Emit a separate
<style>tag per inheritance level with content-aware hrefs, enabling React 19 deduplication of shared base styles - Preserve correct CSS ordering (base before extended) for proper specificity override behavior
- Fix spaces in
-
f674224: Reduce standalone/browser bundle size by making IS_RSC a build-time constant, enabling dead code elimination of RSC-specific branches
[email protected]
Patch Changes
- ca61aca: Fix CSS block comments containing
//(e.g. URLs) causing subsequent styles to not be applied. - a2cd792: Fix
createGlobalStylestyles not being removed when unmounted in RSC environments. React 19'sprecedenceattribute on style tags makes them persist as permanent resources; global styles now render withoutprecedenceso they follow normal component lifecycle. - dbe0aae: In RSC environments,
themeis nowundefinedinstead of{}for styled components, matching the existing behavior ofwithThemeandcreateGlobalStyle. This ensures accessing theme properties without a ThemeProvider correctly throws rather than silently returningundefined. - 1888c73: Fix
withThemeHOC types: ref now correctly resolves to the component instance type instead of the constructor, andthemeis properly optional in the wrapped component's props. - f84f3fa: Fix SSR styles hydration and global style cleanup in Shadow DOM
- 43a5b4b: Optimize internal style processing hot paths: cached GroupedTag index lookups, string fast path in flatten, direct string concatenation in dynamic style generation, pre-built stylis middleware chain with lazy RegExp creation, single-lookup Map operations, VirtualTag append fast-path, and manual string concat in SSR output.
- 788e8c0: Revert
exportsfield and restore browser/server build split withbrowserfield in package.json. Fixesrequire('stream')resolution errors in browser bundlers like webpack 5.
[email protected]
Patch Changes
- 55d05c1: Make react-dom an optional peer dependency, clean up some unnecessary type peers.
[email protected]
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<style data-styled-global>tags. The cleanup effect now removes these hoisted style tags when the component unmounts or re-renders with different CSS.
These changes ensure
createGlobalStyleworks correctly with:- React StrictMode's double-render behavior
- React 18/19's concurrent rendering features
- React 19's style hoisting with the
precedenceattribute - React Server Components (server-defined GlobalStyles in client components)
-
-
51ffa9c: Restore
styled.br. -
1f794b7: Add package.json "exports" field for better native ESM integration.
[email protected]
Patch Changes
- 189bc17: Fix url() CSS function values being incorrectly stripped when using unquoted URLs containing
//(e.g.,url(https://example.com)). The//in protocol URLs likehttps://,http://,file://, and protocol-relative URLs was incorrectly being treated as a JavaScript-style line comment.
[email protected]
Patch Changes
-
7ff7002: Fix: Line comments (
//) in multiline CSS declarations no longer cause parsing errors (fixes #5613)JS-style line comments (
//) placed after multiline declarations likecalc()were not being properly stripped, causing CSS parsing issues. Comments are now correctly removed anywhere in the CSS while preserving valid syntax.Example that now works:
const Box = styled.div` max-height: calc(100px + 200px + 300px); // This comment no longer breaks parsing background-color: green; `;
-
7ff7002: Fix: Contain invalid CSS syntax to just the affected line
In styled-components v6, invalid CSS syntax (like unbalanced braces) could cause all subsequent styles to be ignored. This fix ensures that malformed CSS only affects the specific declaration, not subsequent valid styles.
Example that now works:
const Circle = styled.div` width: 100px; line-height: ${() => '14px}'}; // ⛔️ This malformed line is dropped background-color: green; // ✅ Now preserved (was ignored in v6) `;
[email protected]
Patch Changes
- 8e8c282: Fixed
createGlobalStyleto not useuseLayoutEffecton the server, which was causing a warning and broken styles in v6.3.x. The checktypeof React.useLayoutEffect === 'function'is not reliable for detecting server vs client environments in React 18+, so we now use the__SERVER__build constant instead.
[email protected]
Patch Changes
-
6e4d1e7: fix: suppress false "created dynamically" warnings in React Server Components
The dynamic creation warning check now properly detects RSC environments and skips validation when
IS_RSCis true. This eliminates false warnings for module-level styled components in server components, which were incorrectly flagged due to RSC's different module evaluation context. Module-level styled components in RSC files no longer trigger warnings since they cannot be created inside render functions by definition.
[email protected]
Patch Changes
-
a4b4a6b: fix: include TypeScript declaration files in npm package
Fixed Rollup TypeScript plugin configuration to override tsconfig.json's noEmit setting, ensuring TypeScript declaration files are generated during build.
-
a4b4a6b: fix: resolve TypeScript error blocking type declaration emission
Fixed TypeScript error in StyledComponent when merging style attributes from attrs. Added explicit type cast to React.CSSProperties to safely merge CSS property objects. This error was preventing TypeScript declaration files from being generated during build.