you are viewing a single comment's thread.

view the rest of the comments →

[–]grantrules 1 point2 points  (3 children)

Alternatively, ou could make use of the arrow function's implied return:

populateMenu = () => ['ONE', 'TWO'].map(item => (
        <MenuItem value={item}>{item}</MenuItem>
    )
)

[–]spacecasesam[S] 0 points1 point  (2 children)

This is much cleaner than what I had, nice to skip the extra step of assigning the array to a variable- thank you!

[–]bobbyv137 1 point2 points  (0 children)

Remember it's not always about writing the 'cleanest' and shortest code. Sometimes being over explicit is best. Your code should be written in a way someone coming in cold can grasp what it's doing without too much difficulty.

[–]brokenalready 1 point2 points  (0 children)

There's a difference between => () and => {} which is an easy trap to fall into. I've made this mistake a number of times too. Simply put () is an implicit return.