Reactjs: Arrays in jsx
When I tried out Reactjs tutorial few months ago, I noticed that in the official starter code, they repeated same div
elements in the render()
method, just in case of change in the source, I will list it here:
From the fist look I did not like the repetition, even for a beginner in React, javascript basic array operations should be a familiar topic.
So I refactored that section using the map
operation:
I do not think that this is so complecated to be understood for any React beginner, and I would recommend using similar concise code instead of repeating the same function calls or elements over and over again.
What do you think?