Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defaultProps cannot be set #361

Open
datner opened this issue Jan 1, 2025 · 0 comments
Open

defaultProps cannot be set #361

datner opened this issue Jan 1, 2025 · 0 comments
Assignees
Labels
package: system Specific to @mui/system status: waiting for maintainer These issues haven't been looked at yet by a maintainer

Comments

@datner
Copy link

datner commented Jan 1, 2025

Steps to reproduce

Steps:

const Foo = styled('div')({})
Foo.defaultProps = { role: 'group' }

and save

Current behavior

Cannot create property 'defaultProps' on string '.f1mt11b3'

Expected behavior

Being able to set default props, not necessarily using the method above, just in general

Context

I have a button I want to make sure is not a submit by default, so I want it to have type="button", but I don't want to do the wrapping dance

const _Foo = styled('button')({})
export const Foo = (props: ComponentProps<typeof _Foo>) => 
  <_Foo type="button" {...props} />

Its just needless ritual

Your environment

npx @mui/envinfo
  System:
    OS: macOS 14.6
  Binaries:
    Node: 20.18.0
    npm: 8.12.1
    pnpm: 9.14.4
  Browsers:
    Chrome: Not Found
    Edge: Not Found
    Safari: 17.6
  npmPackages:
    @pigment-css/react: ^0.0.29 => 0.0.29 
    @pigment-css/vite-plugin: ^0.0.29 => 0.0.29 
    @types/react: ^19.0.2 => 19.0.2 
    react: ^19.0.0 => 19.0.0 
    react-dom: ^19.0.0 => 19.0.0 
    typescript: ~5.7.2 => 5.7.2 

Search keywords: props, default, defaultProps

@datner datner added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 1, 2025
@zannager zannager added the package: system Specific to @mui/system label Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: system Specific to @mui/system status: waiting for maintainer These issues haven't been looked at yet by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants