带有样式组件主题的“属性主题在类上不存在...”?

时间:2018-10-17 07:41:23

标签: typescript sass styled-components

这是我的index.tsx:

const theme = require('sass-extract-loader?{"plugins": ["sass-extract-js"]}!./parameters.scss');

...

<Provider store={store}>
    <ConnectedRouter history={history}>
        <ThemeProvider theme={theme}>
            <ScrollToTop>
                <App />
            </ScrollToTop>
        </ThemeProvider>
    </ConnectedRouter>
</Provider>

这是我设计的样式:

import * as React from 'react';
import styled from 'styled-components';

interface FlexContainerProps {
    // tslint:disable-next-line:no-any
    children: any;
}

export default function FlexContainer(props: FlexContainerProps) {
    const Container = styled.div`
        display: flex;
        flex-direction: column;

        @media all and (min-width: ${props.theme.minWidthLargeDevice}) {
            flex-direction: row;
        }
    `;
    return (
        <Container>
            {props.children}
        </Container>
    );
}

我收到错误

Property 'theme' does not exist on type 'FlexContainerProps'.

为什么主题不适用于我的组件?如何摆脱这个错误?

我正在使用样式化组件v4。

0 个答案:

没有答案