0

ReactJS でカルーセルにレンダリングする必要がある画像の配列を持つ JSON スキーマがあります。

api.json

[
  {
    "id": "DR001",
    "propertyFullName": "8838, Brook St, NY",
    "propertyShortName": "Anchorage, AK 99501",
    "features": ["2 beds", "1 bath", "865 sqft"],
    "description": "data.",
    "images": [
      "http://placehold.it/1000x400/ffffff/c0392b/&text=slide1",
      "http://placehold.it/1000x400/ffffff/c0392b/&text=slide2",
      "http://placehold.it/1000x400/ffffff/c0392b/&text=slide3",
      "http://placehold.it/1000x400/ffffff/c0392b/&text=slide4",
      "http://placehold.it/1000x400/ffffff/c0392b/&text=slide5",
      "http://placehold.it/1000x400/ffffff/c0392b/&text=slide6"
    ],
    "status": true
  },
  {
    "id": "DR002",
    "propertyFullName": "8838, Brook St, NY",
    "propertyShortName": "Anchorage, AK 99501",
    "features": ["2 beds", "1 bath", "865 sqft"],
    "description": "data.",
    "images": [
      "http://placehold.it/1000x400/ffffff/c0392b/&text=slide1",
      "http://placehold.it/1000x400/ffffff/c0392b/&text=slide2",
      "http://placehold.it/1000x400/ffffff/c0392b/&text=slide3",
      "http://placehold.it/1000x400/ffffff/c0392b/&text=slide4",
      "http://placehold.it/1000x400/ffffff/c0392b/&text=slide5",
      "http://placehold.it/1000x400/ffffff/c0392b/&text=slide6"
    ]
  }
]

features最初の配列、つまりこのようにハードコーディングしています

{APIData.map((apiData, index) => {
                  return (
                    <>
                      <Heading subtitle>
                        <span name={index}>{apiData.features[0]}</span>
                        <span class="middle-dot" aria-hidden="true">
                          &nbsp;
                        </span>
                        <span>{apiData.features[1]}</span>
                        <span class="middle-dot" aria-hidden="true">
                          &nbsp;
                        </span>
                        <span>{apiData.features[2]}</span> <br />
                        <span>
                          <p>{apiData.description}</p>
                        </span>
                      </Heading>
                      <hr />
                    </>
                  );
                })}

なぜなら、機能が 3 つしかないことはわかっていますが、の場合imagesは動的です。なぜ私はこれを克服するのですか?

画像は別のものでレンダリングされています<div>。私はこのようなことを試しました

            <Carousel {...settings}>
              {APIData.map((images, index) => {
                return (
                  <>{<img src={images.images} alt={index} />}</>
                );
              })}
            </Carousel>
4

2 に答える 2