composi/core

[??] document use with expression functions

Closed this issue · 3 comments

for example (not tested):

const Title = (greet) => (
  h(
    'nav',
    {
      class: 'heading'
    },
    [
      // h(...)
    ]
  )
)

more functional, less imperative

Yes, that pattern works, but it's harder to debug in the browser console because the function is anonymous.

I thought that modern JS engines would detect this kind of a pattern as a function declaration (Babel JS seems to do this), oh well. Closing for now.

To be honest, I do use the pattern occasionally myself. But I tend to use named functions as much as possible. I know it's fashionable for devs these days to use arrow functions as much as possible. I prefer to use them for what they were designed for: lambdas.