I have this Object.map statement in a react component.
{
instagramItems.map((item, index) => (
<div className="row" Key={index}>
<div onClick={() => handleClick(item, index)} className="image-block col-sm-4" style={{
backgroundImage: "url(" + item.media_url + ")",
backgroundPosition: 'center ',
backgroundSize: 'cover',
backgroundRepeat: 'no-repeat'
}}></div>
I want to change the col-sm-X class on a div so the out put repeats this pattern.
col-sm-4
col-sm-8
col-sm-4
col-sm-4
col-sm-4
col-sm-8
col-sm-4
I'm guessing I need to use the Index to calculate what I need to set the class to.
Update:
Though I have marked Yuji 'Tomita' Tomita answer as the correct one. It is not exactly what I wanted...
I want the pattern to repeat not just have diffrent classes for the first and the last. I want the out put to be like this:
http://www.prepbootstrap.com/bootstrap-template/responsive-image-tiles
Can anyone improve the answer?