[英]Typescript says a prop does not exist on a component I wrapped with styled-components
I am using semantic-ui-react and along with styled-components.我正在使用semantic-ui-react 和styled-components。 I am wrapping the Tab component with styled-components to customize its look.
我正在用 styled-components 包装 Tab 组件以自定义其外观。 Here is that code
这是那个代码
const CustomTab = styled(Tab)<{props: TabProps}>`
flex: 1;
display: flex;
margin-top: 10px;
flex-direction: column;
`;
As you can see I am trying to specify that the props for CustomTab
will be the same props as the Tab
component.如您所见,我试图指定
CustomTab
的道具与Tab
组件的道具相同。 I did this based on this answer.我是根据这个答案做的。
The problem is that typescript still seems to think that Menu
props does not exits on my CustomTab
component.问题是打字稿似乎仍然认为
Menu
道具不会在我的CustomTab
组件上退出。
Where am I going wrong?我哪里错了?
Try const CustomTab = styled(Tab)<TabProps>
试试
const CustomTab = styled(Tab)<TabProps>
You basically defined your props as an object that looks like this: {props: {TabProps}}
您基本上将道具定义为一个如下所示的对象:
{props: {TabProps}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.