V
V
Vitaly2017-08-25 10:09:26
React
Vitaly, 2017-08-25 10:09:26

Getting the right attributes of dynamic elements in React?

Hello.
Please share your experience, who uses it how:
suppose something like this is performed in the render:

{items.map((item, key) => (
             <div key={key} className="blaba-class" onClick={(e)=>alert(e.target.key)}>
             //...
))}

The alert will throw undefined , which is basically expected. The question is, is it possible to somehow bind the values ​​\u200b\u200bthat I need to the object without transferring them to the date attributes of the block?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Osher, 2017-08-25
@vshvydky

You can put everything in a separate component. It is possible in the data-* attribute.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question