Open
Description
Hey @luwes. I have been building something with this library for 2 weeks now and it's been great so far.
But, I notice a bit of unusual pattern when building components using JSX.
Since JSX transpiler always pass null
if props
param is empty like:
// JSX
<Component>Hello</Component>
// Transpiled
h(Component, null, "Hello")
In Sinuous, you can't destructure props
like this:
const Component = ({ name, intent, as, icon, onDrag, onDrop }) => {
// Do something with props
return (
<div>
...
</div>
)
}
It throws error simply because props
is null
.
So, you need to this instead:
const Component = (props) => {
let { name, intent, as, icon, onDrag, onDrop } = props || {}
// Do something with props
return (
<div>
...
</div>
)
}
In React you can do that, because React internally checks for null props
and pass {}
instead.
I plan to build a lot of components and this pattern is slightly annoying. Do you mind if I submit a PR?
Thank you