0

class App extends Component {
  render() {
    const tweets = [
      { id: 1, stars: 13, text: 'Turns out "git reset --hard HEAD^" was a terrible idea.' },
      { id: 2, stars: 87, text: 'Tech conferences are too expensive.' },
      { id: 3, stars: 51, text: 'Clean code is subjective. Optimize for deletion.' },
      { id: 4, stars: 19, text: 'Maybe the real benefit of open source was the friendships we made along the way?' },
    ];

    const stars = tweets.map(tweet => tweet.stars);
    console.log(stars);
    return (
      <>
        <ul>
          {
            tweets.map((tweet, index) => (
              <li>{tweet.text}</li>
            ))
          }
        </ul>
      </>
    );
  }
}

export default App;

I am new in React.js, gettig a warning like below. I am getting the errors like that: Warning: Each child in a list should have a unique "key" prop.

nuha ali
  • 29
  • 2
  • 1
    Does this answer your question? [Understanding unique keys for array children in React.js](https://stackoverflow.com/questions/28329382/understanding-unique-keys-for-array-children-in-react-js) – benjamin Rampon May 25 '20 at 12:54
  • 1
    [How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/a/261593/3082296) – adiga May 25 '20 at 12:56

0 Answers0