我们需要那些作为 props 传递的类应该比默认类具有更高优先级的组件。
当将类作为 prop 传递时,组件优先考虑在自己的文件中创建的类。
文本.jsx
// this will be a component in another folder, it will be used in the whole app so it
// should haveDYNAMIC styling
function Text(props) {
const useStyles = makeStyles(theme => ({
default: {
fontSize: 18,
color: "black"
}
}));
const classes = useStyles();
return (
<div className={classNames(classes.default, props.className)}>
{props.children}
</div>
);
}
Run Code Online (Sandbox Code Playgroud)
应用程序.jsx
function App() {
const useStyles = makeStyles(theme => ({
title: {
fontSize: 80,
color: "red"
},
notGoodPractice: {
fontSize: …Run Code Online (Sandbox Code Playgroud)