Home > OS >  Where do I put my interface in the following function?
Where do I put my interface in the following function?

Time:07-07

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 }). 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}
  />
);

CodePudding user response:

This should do the trick(if it doesnt declare LinkTabProps as class):

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