render-props-compose
render-props-compose copied to clipboard
added preact support
Fixes #10 Fixed demo https://codesandbox.io/s/nnmy7jnz0l
Thanks for the feedback. Thinking of it a little bit more, there are 4 cases:
- React:
props.childrenis a function ➡️useprops.children - React:
props.childrenisundefined➡️useprops.render - Preact:
props.childrenis an array with a function ➡️useprops.children[0] - Preact:
props.childrenis an empty array ➡️useprops.render
We handle both case 3 and 4 with props.children[0] as [][0] is undefined, which will be handled like case 2
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