I am trying to iterate through the returned array from render inside return.
class Example extends React.Component {
render() {
let actortype = 1;
const arr1 = ['a', 'b', 'c'];
const arr2 = ['x', 'y', 'z'];
if (actortype == 1) {
var array = [...arr1]; //clone arr1 to array
} else {
var array = [...arr2];
}
return (
<div>
//I want to map through the array returned above in render. I am doing something like this:
array.map((index)=>{
<div>testing</div>
})
// seems not the right approach to access array inside return. returns plain text
</div>
);
}
}
Please share your feedback, how can I do that.