I am trying to render in react, jsx, a loop inside of a loop Like bellow:
{this.state.ans.map(function(item) {
return (
{this.state.quest.map(
function(item1) {return (item1)}
)}
{item}
)
})}
This does not work any other suggestions
You forgot the wrapping div in your first
map
statement:Try it like this:
Basically the idea is that, you should return a single element - in my example a
div
(with the latest react version you don't have to). And moreover, use lambdas in order forthis
to reference the correct context.If you do not use ES6, you can add the following statement at the beginning of the
render
method:and use
that
afterwards with thefunction(){}
syntax inside thereturn
.