Typescript说我用样式化组件包装的组件上不存在道具

问题描述 投票:0回答:1

我正在使用语义UI反应以及样式化组件。我用样式组件包装Tab组件以自定义其外观。这是该代码

const CustomTab = styled(Tab)<{props: TabProps}>`
    flex: 1;
    display: flex;
    margin-top: 10px;
    flex-direction: column;
`;

如您所见,我正在尝试指定CustomTab的道具与Tab组件的道具相同。我是根据this答案进行的。

问题是打字稿似乎仍然认为Menu道具没有在我的CustomTab组件上退出。

我要去哪里错了?

reactjs typescript styled-components semantic-ui-react
1个回答
0
投票

尝试const CustomTab = styled(Tab)<TabProps>

您基本上将道具定义为如下所示的对象:{props: {TabProps}}

© www.soinside.com 2019 - 2024. All rights reserved.