solid-ui icon indicating copy to clipboard operation
solid-ui copied to clipboard

Use `[local, others]` instead of `[, rest]` in splitProps statements

Open jesseb34r opened this issue 7 months ago • 4 comments

@stefan-karger mentioned on discord that splitProps statements should be switched to use a [local, others] pattern to be consistent with how the [solid docs](https://docs.solidjs.com/reference/reactive-utilities/split-props] do it. I am unfamiliar with the full code base architecture here, but as best as I can tell the component code is in apps/docs/src/registry/ui/ so I grepped for the pattern there and found that the Dialog, Drawer, Dropdown Menu, and Resizable components all still use the [, rest] pattern.

jesseb34r avatar Jun 13 '25 16:06 jesseb34r

The recommended pattern in Solid 2.0 will be similar to [, rest], if you prefer waiting to avoid a refactor.

jer3m01 avatar Jun 13 '25 16:06 jer3m01

@jer3m01 Is there documentation or a reference for what the intended pattern is here or conversations on the tradeoff between patterns? I'd be interested in understanding more about this.

jesseb34r avatar Jun 13 '25 16:06 jesseb34r

No documentation yet, but using local you unnecessarily wrap the options you want with an extra proxy.

const [local, rest] = splitProps(props, ["myProp", ...]);

local.myProp // same as
props.myProp

Rest is the only variable you actually need an extra proxy for.

jer3m01 avatar Jun 13 '25 16:06 jer3m01

if you prefer waiting to avoid a refactor.

Depends on how far-off 2.0 is and if I'd need to wait for corvu and kobalte to adapt 2.0 first. :)

stefan-karger avatar Jun 16 '25 18:06 stefan-karger