solid-labels
solid-labels copied to clipboard
Add destructuring defaults to the docs
Edit: the feature is supported, but the docs are outdated
Solid labels supports destructuring with defaults, but the docs are outdated and, in fact, explicitly state that it's not supported. The docs need to be updated to explain the feature.
Previous content:
Taking this babel plugin as an example, it should be doable with mergeProps
:
// Default props using `mergeProps`
import { Component } from 'solid-js'
const MyComp: Component<...> = (
{ a = 1, b = 2, c = 3 } = defaultProps
) => {a; b; c;}
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
import { Component, mergeProps } from 'solid-js'
const MyComp: Component<...> = props => {
props = mergeProps(defaultProps, { a: 1, b: 2, c: 3 }, props);
props.a; props.b; props.c;
}
Wondering if this is something that could be supported here? Thanks!
Default props are already supported through $destructure
and $component
Fun fact: the default props feature in that plugin is based on my plugin.
Oh okay, good to know, seems like the docs are outdated then though:
- https://github.com/lxsmnsyc/solid-labels/blob/main/docs/ctf.md#destructure
And follow up question, are they not supported through labels and comments?
- https://github.com/lxsmnsyc/solid-labels/blob/main/docs/labels.md#destructure
- https://github.com/lxsmnsyc/solid-labels/blob/main/docs/comments.md#destructure
they share the same features so yes
Nice! I'm gonna rename this issue then to focus on the docs.
Well, that took a while