N
N
Nikita Shchypylov2018-05-08 17:09:09
React
Nikita Shchypylov, 2018-05-08 17:09:09

Why does it give an error about duplicate keys if they are unique?

Hello everyone
Gives this error :
Warning: Encountered two children with the same key, `Sister Moons`. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted - the behavior is unsupported and could change in a future version.
For the key I use ID (External API from NASA). These IDs are unique, I checked by creating an array and adding an id to it for this iteration, if there is no such value already. I still get the error. Then I just used index (1,2,3) for key. I got 100 elements, the keys went from 1 to 99 and I still see an error. Interestingly, there are 100 elements, and 70 errors
. Code:

<Element
              classy="post post--image"
              key={value.data[0].nasa_id}
              img={value.links[0].href}
              desc={value.data[0].description}
              title={value.data[0].title}
            />

const Element = ({ classy, img, desc, title }: Props) => {
  return (
    <Card
      className={classy}
      image={img}
      header={title}
      description={desc}
      extra={extra}
    />
  );
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Shchypylov, 2018-05-08
@Nikulio

SOLUTION: DO NOT USE REACT SEMANTIC UI.
This game itself decided to put down the keys for the title and text, and in some elements they are the same (title and text)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question