Skip to content

Conversation

@shayanhabibi
Copy link
Contributor

Add spread functionality pending fable-compiler/Fable#4038

Syntax:

[<SolidComponent>]
let Button (props: SomeObj) =
    let local,others = Solid.splitProps(props, [| "class" |]) // user imported solid splitProps
    button().spread(others) { "I spread 📦" }

output

<button {...others}>I spread 📦 </button>

@shayanhabibi shayanhabibi changed the title [JSX] Enhancement to allow spreading objects within elements [Oxpecker.Solid] Enhancement to allow spreading objects within elements Feb 8, 2025
@shayanhabibi shayanhabibi marked this pull request as draft February 8, 2025 07:03
@Lanayx
Copy link
Owner

Lanayx commented Feb 9, 2025

[<SolidComponent>]
let Button (props: SomeObj) =
    let local,others = Solid.splitProps(props, [| "class" |]) // user imported solid splitProps

I'm not sure it's feasible, the only way I see it can work - if argument and both results will be obj, which would make it pretty unusable.

@shayanhabibi
Copy link
Contributor Author

Indeed, not something I think can be put in Oxpecker atm. If I could perform introspection on host provided types in a type provider I would have been able to produce anonymous records on demand for type safety, but that doesn't seem to be possible.

For the time being, I've implemented it in my own library and return a tuple of the same type that was provided to the function.

Going to use it for translating solid js to oxpecker, but not exported for user use.

@Lanayx
Copy link
Owner

Lanayx commented Feb 10, 2025

Right, I see all those solidjs APIs around props as bunch of hacks, thus didn't want to implement any of those in the first place.

@shayanhabibi
Copy link
Contributor Author

Stale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants