-
Notifications
You must be signed in to change notification settings - Fork 105
Description
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:
- Click on any list item from the first list.
- See on the log console the logged event.
- Click on any list item from the second list.
- 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