Skip to content

StandardListItem: It is not possible to get the list item data by clicking on it #114

@CristianDDias

Description

@CristianDDias

Describe the bug
It is not possible to get the list item data by clicking on it using the onItemClick event from the <List>. The onItemClick event fires a callback function, which receives an event as parameter. Using this event, I can't get the list item data. In my example, I have a list of product objects, which have the properties id and name. In the <StandardListItem> I just use the name property. How can I get the product object from the list of product objects when I click on the list item? Also, I'm using TypeScript, what don't allow me to use a React Element as a children of the <StandardListItem> (in the codesandbox bellow I'm using JavaScript, which allows me to do that).

To Reproduce
https://codesandbox.io/s/intelligent-waterfall-gggot

Steps to reproduce the behavior:

  1. Click on any list item from the first list.
  2. See on the log console the logged event.
  3. Click on any list item from the second list.
  4. See on the log console the logged product id.

Expected behavior
I think each <StandardListItem> should have its own onClick method. A good example is the <ListItem> component from the Material-UI library, which accepts an onClick method.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chrome
  • Version: 76

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions