You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
hotloading styles doesn't unmount the previous style tag #5670
Confirmed — in RSC mode, each HMR style change produces a new content-hash-based href, and React 19 treats each <style precedence="..."> as a separate permanent resource that is never removed. Stale &-based selectors keep matching because they use the stable component ID class.
The fix is to skip precedence on RSC style tags in development mode so React doesn't hoist them as permanent resources. This only affects dev — production styles are immutable so persistence is correct there.
Revised the approach in #5684. Instead of using stable hrefs in dev mode (which causes React 19 to incorrectly deduplicate style tags for dynamic prop variants), the updated fix omits precedence and href entirely in development.
Without these props, React treats <style> as a regular element — not a resource. Regular elements unmount naturally on re-render, so stale style tags from HMR cycles are cleaned up automatically. This avoids the original accumulation issue without introducing dedup bugs for components with dynamic props.
Production behavior is unchanged: content-aware precedence/href are preserved for correct deduplication.
[email protected] is published with the createGlobalStyle shared-group rearchitecture and RSC inline style tag changes (no more precedence/href attributes).
These changes should significantly reduce HMR style accumulation since RSC style tags are now plain inline <style> elements that React doesn't treat as permanent Float resources.
Fixed in [email protected] (PR #5702). The module-level stylesheet singleton now resets once per server render via React.cache, and keyframe rules are emitted in a dedicated <style> tag with separate deduplication. Install with npm i styled-components@test to verify.
Activity
quantizor commentedon Mar 19, 2026
Confirmed — in RSC mode, each HMR style change produces a new content-hash-based
href, and React 19 treats each<style precedence="...">as a separate permanent resource that is never removed. Stale&-based selectors keep matching because they use the stable component ID class.The fix is to skip
precedenceon RSC style tags in development mode so React doesn't hoist them as permanent resources. This only affects dev — production styles are immutable so persistence is correct there.fix: prevent HMR style tag accumulation in RSC mode
quantizor commentedon Mar 19, 2026
Revised the approach in #5684. Instead of using stable hrefs in dev mode (which causes React 19 to incorrectly deduplicate style tags for dynamic prop variants), the updated fix omits
precedenceandhrefentirely in development.Without these props, React treats
<style>as a regular element — not a resource. Regular elements unmount naturally on re-render, so stale style tags from HMR cycles are cleaned up automatically. This avoids the original accumulation issue without introducing dedup bugs for components with dynamic props.Production behavior is unchanged: content-aware
precedence/hrefare preserved for correct deduplication.You can test with
[email protected].quantizor commentedon Mar 21, 2026
[email protected]is published with thecreateGlobalStyleshared-group rearchitecture and RSC inline style tag changes (no moreprecedence/hrefattributes).These changes should significantly reduce HMR style accumulation since RSC style tags are now plain inline
<style>elements that React doesn't treat as permanent Float resources.See Version Packages PR #5687 for the full changelog.
Please test with
npm i [email protected]and report back.fix: prevent RSC style tag accumulation across HMR cycles (#5670)
fix(rsc): prevent style tag accumulation across HMR cycles
quantizor commentedon Mar 24, 2026
Fixed in
[email protected](PR #5702). The module-level stylesheet singleton now resets once per server render viaReact.cache, and keyframe rules are emitted in a dedicated<style>tag with separate deduplication. Install withnpm i styled-components@testto verify.fix: prevent RSC style tag accumulation across HMR cycles (styled-com…