I am using react version 17 and we use webpack to bundle our deps.
import React from "react";
import { Chip } from "@material-ui/core";
import {
createGenerateClassName,
createStyles,
makeStyles,
StylesProvider,
Theme,
} from "@material-ui/core/styles";
// eslint-disable-next-line import/no-extraneous-dependencies
import { create } from "jss";
import shortid from "shortid";
const generateClassName = createGenerateClassName({
productionPrefix: "my-prod-",
seed: shortid.generate(),
});
const useStyles = makeStyles((theme: Theme) =>
createStyles({
whiteText: {
color: "white",
backgroundColor: "rgb(24, 190, 148)",
},
redText: {
color: "white",
backgroundColor: "rgb(233, 109, 118)",
},
grayText: {
color: "gray",
backgroundColor: "rgb(238,228,228)",
},
})
);
const Synced = "Synced";
const OutOfSync = "OutOfSync";
const Unknown = "Unknown";
const SyncStatusChip = ({ status }) => {
const classes = useStyles();
return (
<StylesProvider generateClassName={generateClassName}>
{status === Synced && <Chip size="small" label={status} className={classes.whiteText} />}
{status === OutOfSync && <Chip size="small" label={status} className={classes.redText} />}
{status === Unknown && <Chip size="small" label={status} className={classes.grayText} />}
</StylesProvider>
);
};
export default SyncStatusChip;
I read a lot of documentation and answers regarding the modification of class names. In our production builds whenever we use make styles we see that it adds a class that start with jss. Problem is that these names sometimes collide with other random generated class names and it creates a lot of UI issues.
even trying my own generate method to generate class names, i still see this stupid class names that start with jss. Sometimes, i wish i wasn't doing frontend. :/
