Skip to content

[Oxpecker.Solid] Enhancement to allow spreading objects within elements - #51

Closed
shayanhabibi wants to merge 1 commit into
Lanayx:developfrom
shayanhabibi:SpreadFt
Closed

[Oxpecker.Solid] Enhancement to allow spreading objects within elements#51
shayanhabibi wants to merge 1 commit into
Lanayx:developfrom
shayanhabibi:SpreadFt

Conversation

@shayanhabibi

Copy link
Copy Markdown
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

Lanayx commented Feb 9, 2025

Copy link
Copy Markdown
Owner
[<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
Copy Markdown
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

Lanayx commented Feb 10, 2025

Copy link
Copy Markdown
Owner

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
Copy Markdown
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