render-props-compose icon indicating copy to clipboard operation
render-props-compose copied to clipboard

added preact support

Open Pyrolistical opened this issue 7 years ago • 2 comments

Fixes #10 Fixed demo https://codesandbox.io/s/nnmy7jnz0l

Pyrolistical avatar Jun 08 '18 21:06 Pyrolistical

Thanks for the feedback. Thinking of it a little bit more, there are 4 cases:

  1. React: props.children is a function ➡️use props.children
  2. React: props.children is undefined ➡️use props.render
  3. Preact: props.children is an array with a function ➡️use props.children[0]
  4. Preact: props.children is an empty array ➡️use props.render

We handle both case 3 and 4 with props.children[0] as [][0] is undefined, which will be handled like case 2

Pyrolistical avatar Jun 08 '18 22:06 Pyrolistical

btw, you might want to do a prettier commit. I stripped out a bunch of pre-commit hook formatting changes to keep this pr simple

Pyrolistical avatar Jun 08 '18 22:06 Pyrolistical