by asherah · 3y ago · 0 comments
run(() => { return foo })
looks better than, and assuming pre-existing knowledge of what `run` does, is more understandable than (() => { return foo })()
but this is also a fairly contrived exampleNew abstractions have a cost, and "clever" abstractions tend to confuse the average developer more than the benefit they provide.
If there's a problem with an IIFE (yes, they can be abused), the usual approach is to replace it with a named function definition. This works in their React example as well--rather than (necessarily) creating a new component as they suggest, the standard approach is to add a named rendering helper in the function closure that returns JSX.