Skip to content

Button props spilling to DOM element #2351

Description

@cbix

Description

The Button props leadingIcon, trailingIcon, variant and size are being passed down to the button or custom (polymorphic) component, leading to React warnings like

Warning: React does not recognize the `leadingIcon` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `leadingicon` instead. If you accidentally passed it from a parent component, remove it from the DOM element.

This happens because these props are not destructured like the others, however they serve no purpose outside the ButtonBase logic:

const {leadingIcon: LeadingIcon, trailingIcon: TrailingIcon, variant = 'default', size = 'medium'} = props

<StyledButton as={Component} sx={merge(sxStyles, sxProp as SxProp)} {...props} ref={forwardedRef}>

Steps to reproduce

With this code using react-router

<Button variant="outline" leadingIcon={MarkGithubIcon} as={Link} to="/github">Test</Button>

and development mode, check the console logs, they should give the warning mentioned above.

Version

v35.6.0

Browser

Chrome

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingreact

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions