Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6215

How to create unique keys for react Components

$
0
0

So, I've got this component here, which If I don't give unique keys, React renders it incorrectly.I can't give this: key={${name}${index}} as a key because name for each element can be edited so this will cause remount... So, How I make these keys unique? just giving index doesn't work...

{stringArray.map((name, index) => (<Component          key={`${index}_${name}}`}          name={name}          index={index}          onChange={onNameChange}          onDelete={onNameDelete}        />      ))}

Viewing all articles
Browse latest Browse all 6215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>