Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
81 views
in Technique[技术] by (71.8m points)

javascript - How to make 3 column row from API data in React

First time doing this so please bear with me.

Using Bootstrap. Trying to make some data present itself as a 3 column row. And at the end of each row, make a new row.

Is there a way to do this with the code below?

Code sandbox here.

Here's the code:

      <input
        className="search"
        type="text"
        placeholder="Search by model..."
        onChange={(e) => setSearchValue(e.target.value)}
        value={searchValue}
      />
      {/* Map through first level */}
      {data.map((item) => (
        <ul>
          {/* Filter and map through the second level */}
          {item.product_details.filter(filterProducts).map((subItem) => (
            <div className="row">
              <div className="col-lg-4">
                <MachineCard
                  image={subItem.image}
                  title={subItem.model}
                  weight={subItem.operating_weight}
                  power={subItem.power}
                />
              </div>
            </div>
          ))}
        </ul>
      ))}
question from:https://stackoverflow.com/questions/65924078/how-to-make-3-column-row-from-api-data-in-react

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...