question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to pass classes

See original GitHub issue
const styleSheetExport = createStyleSheet('OverridesClassNames',{
  root: {
      "flex-flow": "column",
  },
 baseline: {
   "align-items": "baseline"
    ....
}
});

@withStyle(styleSheetExport)
class XListItem extends React.Component{
...
render(){
    const {doBaseline,...others} = this.props;
    return(
      <ListItem className={className(
            [others.classes.baseline]: doBaseline,
            others.className
       )}>
     </ListItem>
    );
}
}


It gives me error like

browser.js:49 Warning: Material-UI: the key `baseline` provided to the classes property object is not implemented in ListItem.
You can only overrides one of the following: root,container,keyboardFocused,default,dense,disabled,divider,gutters,button,.MuiListItem-button-
639905455:hover,.MuiListItem-button-639905455:hover.MuiListItem-disabled-2599742339

How would i add extra stylesheet classes along with overriding some classes ?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
oliviertassinaricommented, Feb 1, 2018

@mgsakata It’s expected:

import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from 'material-ui/styles';

const styles2 = {
  root: {
    margin: 20
  }
};

let Component2 = () => {
- const { classes } = this.props;
+ const { classes, parentClasses } = this.props;
  return (
    <div className={classes.root}>
-     <h1>Child Component!</h1>
+     <h1 className={parentClasses.button}>Child Component!</h1>
    </div>
  )
}


Component2.propTypes = {
  classes: PropTypes.object.isRequired,
};


Component2 = withStyles(styles2)(Component2);

const styles1 = {
  button: {
    margin: 20
  }
};

let Component1 = function () {
  const { classes } = this.props;
  return (
-   <ChildComponent {...this.props} />
+   <ChildComponent parentClasses={classes} />
  )
}

Component1.propTypes = {
  classes: PropTypes.object.isRequired,
};

Component1 = withStyles(styles1)(Component1)

export default Component1
2reactions
mgsakatacommented, Feb 1, 2018

Hello. I am having a very similar issue. Passing the props to child components results in the Warning about the key provided is not implemented. I am not certain if I am doing something opposed to Material-UI style overrides or if it is something which legitimately needs fixing?

Warning message from the codesandbox.io example: Warning: Material-UI: the key button provided to the classes property is not implemented in ChildComponent. You can only override one of the following: root

As suggested I created a Codesandbox.io example. https://codesandbox.io/s/rmypz926o4

To avoid the Warning I’ve found that doing something similar to: <ChildComponent {...this.props} classes={{}} /> Prevents the error since the classes aren’t passed down to the child component.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What should I do if I am unable to pass just one class ... - Quora
If it was in college were you failed the class, then there you will retake the class when they offer it again. Remember...
Read more >
How to Pass a Class You are Failing? Try this Strategy!
How to Pass a Class You Are Failing · 1. Adjust your study habits · 2. Ask for help · 3. Stop procrastinating...
Read more >
Fail a Class in College? Here's What to Do Next
Failing a class in college can be scary, but it isn't the end of the world. Here are six steps you can take...
Read more >
Failing Classes in College? Here's 5 Steps to Save Your ...
If it's not too late, take the class Pass or No Pass (or Pass/Fail depending on what your college calls it). This way,...
Read more >
What Happens If You Fail A Class 3 Times In College? (FIND ...
What happens if you fail a class 3 times in college will depend on the college you are attending, but often, you might...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found