material-ui:v4.8.2
反应:v16.12.0
带有rtl应用程序的babel-plugin-react-css-modules-我以为使用injectFirst,但随后得到警告: Material-UI: you cannot use the jss and injectFirst props at the same time.
我的猜测是我应该对jss进行不同的定义,以便它支持rtl和css模块。
// Configure JSS - How should I add here the css-modules styles?
const jss = create({ plugins: [...jssPreset().plugins, rtl()] });
对于rtl,我应该这样做:
// Configure JSS
const jss = create({ plugins: [...jssPreset().plugins, rtl()] });
<StylesProvider jss={jss}>
<ThemeProvider theme={theme}>
<AppContainer />
</ThemeProvider>);
</StylesProvider>
对于CSS模块样式,我应该这样做:
<StylesProvider injectFirst>
<ThemeProvider theme={theme}>
<AppContainer />
</ThemeProvider>);
</StylesProvider>
谁能建议我将两者结合起来吗?
终于解决了。
请执行下列操作:
jss-insertion-point
在下面添加<head>
<head>
<!-- jss-insertion-point -->
...
</head>
Root.js:
import rtl from 'jss-rtl';
import { StylesProvider, jssPreset } from '@material-ui/core/styles';
let jss = create({
plugins: [...jssPreset().plugins, rtl()],
insertionPoint: 'jss-insertion-point',
});
const Root = () => (
<Provider store={store}>
<StylesProvider jss={jss}>
<ThemeProvider theme={theme}>
<Router history={history} routes={routes}/>
</ThemeProvider>);
</StylesProvider>
</Provider>
);
export default Root;
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句