Conditional Rendering in React js

前端 未结 3 2053
清歌不尽
清歌不尽 2020-12-07 04:55

I have added a condition in rendering and suddenly it stops displaying. Here is the code am using.

 {this.state.sdata.map((sdata, i) => 
   {i < 5 &am         


        
3条回答
  •  星月不相逢
    2020-12-07 05:45

    {this.state.sdata.map((sdata, i) => 
         (i < 4 && 
           this.handleSelect(i)}{...sdata} /> 
         )
       )
    }
    

    Just replace the {} with () like shown above and to show 4 data you have to provide less than 4 because i starts with 0.

提交回复
热议问题