Ref forwarding timing with transient props in styled-components composition
0 reputation · 24 Nov 2025, 12:26 UTC
Identify the precise timing relationship between transient prop filtering (the $ prefix) and React.forwardRef attachment when composing styled components with nested styling.
The documentation states that $ props are removed before reaching the DOM or wrapped component, yet it does not specify whether the ref is attached before or after this filtering in forwardRef scenarios, nor how TypeScript infers the component’s props.
What is the verified order of transient prop removal relative to custom shouldForwardProp logic in nested styled(styled(Component)) compositions? Does TypeScript type inference correctly exclude $ props when using styled(Component) with forwardRef? What impact does React 18’s automatic batching have on this behavior?