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

442
Visualizações
React Typescript: Ant Design Table with Dropdown Column pass Record to function

Following Column:

{ title: "Action", render: (record: ToDoClass) => { //<- this record
   return (
      <Dropdown overlay={menu}>
         <Button>
            User <DownOutlined />
         </Button>
      </Dropdown>
   )
}},

has the menu:

const menu = (
   <Menu onClick={updateUser}>
      <Menu.Item key="0" />
      <Menu.Item key="1">User 1</Menu.Item>
      <Menu.Item key="2">User 2</Menu.Item>
   </Menu>
);

must call the function: updateUser with the parameter record from the columns and key from the menu:

const updateUser = ({ key }: { key: React.Key }): void => { //<- need record here
   console.log(key);
};
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Based on the documentation, the onClick prop takes a function that takes an object { item, key, keyPath, domEvent }. You can try changing your _updateUser and menu to something like this:

<Menu onClick={this._updateUser}>
...
private _updateUser = ({ item, key }: { item: ToDoClass, key: any }): void => {
   console.log(item, key);
}

Here is an example I created based on your code. Note the difference on how onClick is assigned. Also, since item is circular, it will crash the browser when it is printed.

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