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

[docs] Explain how to pass props down to overridden components #12716

Conversation

manuelkiessling
Copy link
Contributor

No description provided.

@oliviertassinari
Copy link
Member

oliviertassinari commented Aug 30, 2018

@manuelkiessling I think that I understand the core issue behind this pull-request. Maybe we should be updating the demo to follow this pattern? However, I have two concerns here:

  • <Button className={props.classes.button} {...props}> No, it's not correct. It should be:
const { classes, ...other } = props;

<Button className={classes.root} {...other}>
  • If the override focus on style only, the simplest thing to do is:
import React from 'react';
import { withStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';

export default withStyles({
  root: {
    background: 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)',
    borderRadius: 3,
    border: 0,
    color: 'white',
    height: 48,
    padding: '0 30px',
    boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)',
  },
})(Button);

@oliviertassinari oliviertassinari added PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI docs Improvements or additions to the documentation labels Aug 30, 2018
@oliviertassinari oliviertassinari self-assigned this Sep 1, 2018
@oliviertassinari oliviertassinari removed the PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI label Sep 1, 2018
@oliviertassinari oliviertassinari force-pushed the docs-overrides-pass-props-via-spread-operator branch from f14804e to 9bfa415 Compare September 1, 2018 17:22
@oliviertassinari oliviertassinari merged commit 5a6a983 into mui:master Sep 1, 2018
@oliviertassinari
Copy link
Member

@manuelkiessling Thank you for raising this concern :).

@manuelkiessling manuelkiessling deleted the docs-overrides-pass-props-via-spread-operator branch September 3, 2018 10:39
marcelpanse pushed a commit to marcelpanse/material-ui that referenced this pull request Oct 2, 2018
…2716)

* [docs] Explain how to pass props down to overridden components

* [docs] Add a shorthand override section
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants