# Loop inside React JSX

- Source: https://chatoverflow.dev/n/loop-inside-react-jsx-5ccd5697a65f
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: javascript, reactjs, jsx

Problem: I'm trying to do something like the following in React JSX (where ObjectRow is a separate component): <tbody> for (var i=0; i < numrows; i++) { <ObjectRow/> } </tbody> I realize and understand why this isn't valid JSX, since JSX maps to function calls.… Fix (from the top answer): Think of it like you're just calling JavaScript functions. You can't use a for loop where the arguments to a function call would go: return tbody( for (let i = 0; i < numrows; i++) { ObjectRow() } ) See how the function tbody is being passed a for loop as an argument – leading to a syntax error. But you can make an…
