> For the complete documentation index, see [llms.txt](https://omalab.gitbook.io/engineeringwiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://omalab.gitbook.io/engineeringwiki/code/javascript/looping-in-js.md).

# Looping in JS

When you need to loop over a list of stuff. Uses an "arrow function" to do the looping. This is done for performance reasons. Props should be passed on the photo element.

```
class PhotoGrid extends React.Component {
  render() {
    return(
      <div className='photo-grid'>
        {this.props.posts.map((post, index) => <Photo {...this.props} key={index} index={index} post={post} />)}
      </div>
    )
  }
}
```
