Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

131
Visualizações
Typescript in storybook with props type using parameter

I have a component:

type RowItem<T> = Record<keyof T, any>;
type TableRowsCells<T> = Array<RowItem<T>>;
type TableHeadCells<T> = HeadCell<T>[];

type TableProps<T> = {
  ariaLabel: string;
  ariaLabelledBy: string;
  TableHeadCells: TableHeadCells<T>;
  TableRowsCells: TableRowsCells<T>;
  defaultOrderBy?: keyof T;
};

function Table<T>(props: TableProps){
  // ---------------.
  // code stuff.
  // ---------------.
}

I am writing the corresponding storybook

import { Story } from '@storybook/react';


export default {
  title: 'Table',
  component: Table,
};

const Template: Story<TableProps> = (args) => <Table {...args} />;

export const Basic = Template.bind({});
Basic.args = {};

I get error from storybook:

The generic type 'TableProps' requires 1 type argument(s).

How can I specify? write? declare? the argument in storybook with this way?

Thx

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

TableProps is a generic type itself so you need to pass its generic type

for example, the code below specifies any as TableProps's generic type

   const Template: Story<TableProps<any>> = (args) => <Table {...args} />;
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda