Search code examples
reactjsantd

Ant design table click on tabel cell


https://codesandbox.io/s/7mo0rvl971

Check this example. You guys can notice that we can click on the name because they use the tag

How can I click the name and get the content. For example, I click the cell 'John Brown' and I get back string 'John Brown'


Solution

  • Solution is that you set data-id on

    <a data-id={text} onClick={this.onClick}>{text}</a>
    

    Then

    onClick = (e) => {
        console.log('Content: ', e.currentTarget.dataset.id);
      }