AlexZ33 / lessions

自己练习的各种demo和课程
12 stars 2 forks source link

[React app ] Each child in a list should have a unique "key" prop #124

Open AlexZ33 opened 1 year ago

AlexZ33 commented 1 year ago

image

代码内添加 key={item.id}

// return 内
 <div className="w-full h-[.76rem] px-[.88rem]  flex justify-between items-start relative">
          {TabsArr.map((item, index) => (
            <div
              key={item.id}
              id={item.id}
              className="flex h-full flex-col justify-between items-center"
              onClick={() => {
                navigate(`/home/${item.type}`, {
                  replace: true,
                });
              }}
            >
              <p
                style={{
                  color:
                    item.type === currentTab
                      ? "#14B9C7"
                      : isDarkMode()
                      ? "rgba(255,255,255,.9)"
                      : "rgba(0,0,0,.8)",
                }}
                className="text-[.42rem] leading-[.56rem]"
                key={index}
              >
                {item.name}
              </p>
            </div>
          ))}
        </div>