0

I'm building a piano app on React . I've created a array for storing note like this :

const notes = ["C", "D", "E", "F", "G", "A", "B"];

then I've mapped it like this :

<ul>
    {notes.map((note) => {
      if (note === "C") {
        return (
          <>
            <li key={note}>{note}</li>
            <li key={`${note}#`}>{note}#</li>
          </>
        );
      }
      return (
        <li key={note}>{note}</li>
      );
    })}
  </ul>

But ReactJS always pop the warning about unique key in list items . I've belived the problem is this :

<li key={`${note.id}#`}>{note.note}#</li>

But I can't quite understand why ( tried to log the key part in the console and they all look unique to me ). Can anyone explain this for me ? Thank in advance .

Dusttt
  • 19
  • 6
  • I *completely* misread this, I have no idea what I was thinking. – Dave Newton Jul 04 '21 at 12:21