`h` props to behave more like React
- Dominant language
- JavaScript
- Stars
- 1.1k
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
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
// JSX
Hello
// Transpiled
h(Component, null, "Hello")
```
In Sinuous, you can't destructure `props` like this:
```jsx
const Component = ({ name, intent, as, icon, onDrag, onDrop }) => {
// Do something with props
return (
...
)
}
```
It throws error simply because `props` is `null`.
So, you need to this instead:
```jsx
const Component = (props) => {
let { name, intent, as, icon, onDrag, onDrop } = props || {}
// Do something with props
return (
...
)
}
```
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
Contributor guide
No contributing guide indexed for this repository
Research direction
No source file, test, or entry point is named. Trace how JSX calls h when props are null, then verify that components can destructure props without a fallback and cover the empty-props case; done means the shown JSX pattern no longer throws.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100