Material-UI injectFirst不适用于故事书

时间:2019-10-30 07:58:59

标签: reactjs material-ui styled-components storybook

根据documentation,我正在使用具有样式组件的material-UI,为了覆盖材料样式,需要添加以下injectFirst属性:

但是,当尝试在故事书环境中使用此方法时,它无法按预期工作,并且仍在样式化组件之后注入JSS样式。

.storybook / config.js:

import React from 'react'
import {configure, addDecorator} from '@storybook/react'
import { StylesProvider } from '@material-ui/styles'

addDecorator(storyFn => (
    <StylesProvider injectFirst>
        { storyFn() }
    </StylesProvider>
));
const req = require.context('../packages', true, /.story.js$/);

function loadStories() {
    req.keys().forEach((filename) => req(filename));
}

configure(loadStories, module);

DOM: styled-components样式属性仍在JSS之前 styled-components style attribute is still before JSS

0 个答案:

没有答案