Reputation: 28154
I need a unique identifier for children of a Reactjs component. Here is JSX pseudo-code:
<ParentComponent>
<htmlElement1 uniqueIdentifier="htmlElement1" />
<htmlElement2 uniqueIdentifier="htmlElement2" />
<ReactElement1 uniqueIdentifier="ReactElement1" />
<ReactElement2 uniqueIdentifier="ReactElement2" />
</ParentComponent>
If I only had React elements I would use key
, but I also have to handle html elements.
I cannot use id
because my app is embedded in a page along with other apps and there might be a conflict.
I am currently using title
but then it doesn't look good as the identifier gets displayed when the user hovers over the element.
Could you recommend a better attribute/prop?
Upvotes: 0
Views: 513