1nwf / Produx-v2

Avoid using an element's index as the key prop JS-0437
Bug risk
Major
8 months ago2 years old
Do not use Array index in keys
10      {data &&
11        products.map((obj, idx) => {
12          return (
13            <div className="mb-10" key={idx}>14              {obj.images ? (
15                <>
16                  <div className="card w-72 card-bordered card-compact lg:card-normal border-solid border-black bg-white">
12            <h1 className="font-bold text-xl">Latest Products</h1>
13            {data.map((p, idx) => {
14              return (
15                <div key={idx}>16                  <ProductCard  product={p} showDesc={true} />
17                </div>
18              );
20        {data
21          ? products.map((product, idx) => {
22              return (
23                <div key={idx}>24                  <div
25                    onClick={() =>
26                         router.push(`products/${product.name}`)
 81                            ref={idx == posts.length - 1 ? lastPostRef : null}
 82                        >
 83                            <Post
 84                                key={idx} 85                                showProductIcon={true}
 86                                data={p}
 87                                channel={channel}
 77                posts.map((p, idx) => {
 78                    return (
 79                        <div
 80                            key={idx} 81                            ref={idx == posts.length - 1 ? lastPostRef : null}
 82                        >
 83                            <Post