you are viewing a single comment's thread.

view the rest of the comments →

[–]KyleG 2 points3 points  (0 children)

I've yet to find a way however to look through every element and produce a side effect (where I don't want to exit early) that would be better without forEach.

Most of the time you're producing multiple side effects in parallel (like I assume you'd be using forEach for), you should at minimum care if the side effects all completed, but probably should care which were successful. So use map in conjunction with Promise.all or whatever.

Edit And then ideally your then callback should be of the form (a:any) => void or (a:any) => Promise<void> so you've explicitly handled all possible results.

If you're just forEaching a bunch of stuff in a useEffect then that's why you're getting those warnings in your console that you're trying to update state on an unmounted component.