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

[styles] Theme default props are overriden by Component default props #20090

Closed
2 tasks done
adridavid opened this issue Mar 12, 2020 · 1 comment · Fixed by #20091
Closed
2 tasks done

[styles] Theme default props are overriden by Component default props #20090

adridavid opened this issue Mar 12, 2020 · 1 comment · Fixed by #20091
Labels
package: system Specific to @mui/system

Comments

@adridavid
Copy link
Contributor

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

Using withStyles, theme default props are overriden by Component default props.

// Component
import Button from "@material-ui/core/Button";

const MyButton = props => <Button {...props} />;
MyButton.defaultProps = { variant: "outlined" };
const MyStyledButton = withStyles({}, { name: "MyButton" })(MyButton);

// Theme
const theme = createMuiTheme({
  props: {
    MyButton: {
      variant: "contained"
    }
  }
});

In the example above, the button will be outlined. It should be contained.

Moreover we don't have the same behavior if we use props destructuring with default values instead of defaultProps. In this case, the button would be contained.
Theme props work as expected for Material-UI components because they use props destructuring.

Expected Behavior 🤔

Theme default props should override Component default props.

Steps to Reproduce 🕹

A code sandbox example is available here.

@adridavid adridavid changed the title [styles] Theme default props are overrides by Component default props [styles] Theme default props are overriden by Component default props Mar 12, 2020
@oliviertassinari

This comment has been minimized.

@zannager zannager added the package: system Specific to @mui/system label Dec 20, 2022
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants