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
Default props inconsistency between React 19 and styled components #5807
typeProps={type?: 'button'|'submit'|'reset';children?: ReactNode}// beforeexportconstButton: FC<Props>=({ type, children })=>{return<buttontype={type}>{children}</button>}Button.defaultProps={type: 'button'}// afterexportconstButton: FC<Props>=({ type ='button', children })=>{return<buttontype={type}>{children}</button>}
With Styled Components the similar effect can be archived by using function in .attrs():
exportconstStyledButton=styled.button.attrs(({ type ='button', ...rest})=>({ type, ...rest}))``
The Issue
Explicit undefined <StyledButton type={undefined} /> somehow ignores the default attribute value. This became quite painful when application code contains mixed styled / es6 components. It is impossible to predict which attribute value will be used without looking for the actual component implementation. Especially when components pass spread ...rest props like <StyledButton {...props} /> down to its grand- (grand-) children.
Reason for this issue
codebase contains two "defaultProps-flavored" types of components: es6-flavored and styled-flavored
hard to convert non-styled components to styled components (this requires finding all usages and checking for correct default values)
Possible solution
<StyledButton type={undefined} /> behaves the same way as <StyledButton /> which is the same as ES6 defaults and defaultProps
Activity
pullfrog commentedon Sep 1, 2026
6.x maintenance: attrs and undefined props, RSC global styles, types …
quantizor commentedon Nov 25, 2026
Fixed in 6.7