简体   繁体   English

我在哪里将我的界面放在以下函数中?

[英]Where do I put my interface in the following function?

This is my Interface that I want to put in the props, but I dont know where to put it.这是我想放在道具中的界面,但我不知道放在哪里。

interface LinkTabProps {
    label: string;
    href: string;
};

This is the function.这就是功能。 I assume it should be put somehwere around (props: { label, href }).我认为它应该放在某个地方(道具:{标签,href})。 But I cant figure out where.但我不知道在哪里。

const LinkTab = (props: { label, href }) => (
  <Tab
    component="a"
    onClick={(event) => event.preventDefault()}
    /* eslint-disable-next-line react/jsx-props-no-spreading */
    {...props}
  />
);

This should do the trick(if it doesnt declare LinkTabProps as class):这应该可以解决问题(如果它没有将 LinkTabProps 声明为类):

const LinkTab = (props: LinkTabProps) => (
  <Tab
    component="a"
    onClick={(event) => event.preventDefault()}
    /* eslint-disable-next-line react/jsx-props-no-spreading */
    {...props}
  />
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我将编码逻辑放在我的 React 应用程序中的什么位置 - Where do I put coding logic in my React Application 在这个 axios 请求中我应该把我的配置放在哪里? - Where do I put my config in this axios request? 在 Typescript 反应组件中,我应该将助手 function 放在哪里? - Where do I put a helper function in a Typescript react component? 尝试调用谷歌云函数,CloudFunctionsServiceClient 中函数 URL 和 /path/to/credentials.json 应该放在哪里? - Trying to Call Google Cloud Function, Where Do I Put The Function URL And /path/to/credentials.json in CloudFunctionsServiceClient? 我应该在 React/React Native 组件中的哪个位置放置函数? 我看到三个选项 - Where inside a React/React Native component do I put a function? I see three options 我应该把 MuiThemeProvider 组件放在哪里? - Where Do I put the MuiThemeProvider Component? 我应该把这段代码放在哪里让我的图标显示出来? - Where do I put this piece of code to get my icons to show up? 我在 React.JS 应用程序中放置静态文件的位置是什么? - Where do I put static files in my React.JS app? 在我的 OrderBy function 中,我在哪里使用我的字符串来转换数字 function? - Where do I use my string to numerical function in my OrderBy function? 我应该把我的调度放在生命周期反应 redux - Where should I put my dispatch in lifecycle react redux
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM