Skip to content

Possible to get access to cx when using withStyles? #80

Discussion options

You must be logged in to vote

Hi @rlansky-percipient,
Thanks for the kind words.
I am not sure that I understand exactly how you would use cx with withStyles but do you know that you can import directly useStyles from tss-react/mui without having to first generate it using makeStyles.
It returns cx and css.

import { withStyles, useStyles } from "tss-react/mui";

type Props = {
  className?: string;
};

const MyComponent = (props: Props) => {

  const { className } = props;

  const { cx, css } = useStyles();

  return (
    <div className={cx(css({ "height": 300 }), className)}>
      {/*...*/}
    </div>
  );

};

const MyComponentStyled= withStyles(
  MyComponent,
  {
    "root": {
      "width": 200
    }
  }
);

I …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rlansky-percipient
Comment options

Answer selected by rlansky-percipient
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants