How do I fix "Expected to return a value at the end of arrow function" warning?

Ramzan Chasygov picture Ramzan Chasygov · Jul 10, 2017 · Viewed 114k times · Source

Everything works fine, but I have this warning Expected to return a value at the end of arrow function array-callback-return. I tried using forEach instead of map, but then <CommentItem /> doesn't even show. How do I fix this?

Answer

Zanon picture Zanon · Jan 14, 2018

A map() creates an array, so a return is expected for all code paths (if/elses).

If you don't want an array or to return data, use forEach instead.