hearty
hearty

Reputation: 731

How to render a div element several times using map?

I have div element which I want to render several times for each element of the array in React. Right now I am rendering a component using the map method but how to render a div in that manner. This is how I render the component

<div class="expndmid">
{
    this.state.shopd.map((cat) => (<ShopsCatOptions shop={cat}/>))                
}
</div> 

How to render a div in that manner instead of creating a component I want to render the data(this.state.shopd) inside the div. How to do it?

Upvotes: 0

Views: 599

Answers (1)

Mamun
Mamun

Reputation: 68933

Try the following:

<div class="expndmid">
{
   this.state.shopd.map((cat) => (
      <div shop={cat}> {cat} </div>
   ))  
}
</div>

Upvotes: 1

Related Questions