使用样式组件时,如何使该警告消失? -className属性未传递给孩子

时间:2019-06-12 02:38:20

标签: styled-components

我有一个styled-component,当它在页面上呈现时,我收到一条警告,我想了解如何解决。这是我的组件:

const TitleBar = styled.nav`
    background-color: #2f323b;
    display: flex;
    height: 60px;
`;

const Link = styled.a`
    display: flex;
    align-items: center;
    font-size: 18px;
    line-height: 20px;
`;

const Wrapper = styled.div`
    margin-left: 15px;
`;

export default () => 
    <TitleBar>
        <Link>
            <Wrapper>
                <BrandInverse />
            </Wrapper>
        </Link>
    </TitleBar>    

这是应用程序中我使用nav元素的唯一位置。这是我得到的警告:

It looks like you've wrapped styled() around your React component (nav), but the className prop is not being passed down to a child. No styles will be rendered unless className is composed within your React component.

为什么会这样?我该如何解决?将来执行此操作的正确方法是什么?

0 个答案:

没有答案