fable-compiler / Fable.Solid

Fable bindings for SolidJS
http://fable.io/Fable.Solid/
MIT License
49 stars 5 forks source link

Missing SolidJS component - `ErrorBoundary` #11

Closed semuserable closed 1 year ago

semuserable commented 1 year ago

https://www.solidjs.com/tutorial/flow_error_boundary

<ErrorBoundary fallback={err => err}>
  <Broken />
</ErrorBoundary>
alfonsogarciacaro commented 1 year ago

It shouldn't be too difficult to add this and the other APIs you asked for. I'll try to do it over the weekend 👍

semuserable commented 1 year ago

Thank you very much @alfonsogarciacaro!

As an example, I thought about something like this

type Solid =
  [<ImportMember("solid-js"); JSX.Component>]
  static member ErrorBoundary(fallback: JSX.Element, children: JSX.Element): JSX.Element = jsNative

But it covers only one flow for fallback. I guess I should be using U2 to cover TypeScript OR type definition, but I don't know for sure. Also, original TypeScript definition returns Accessor<JSX.Element> and if I interop that it won't work as JSX.Element is expected. I checked how you did it for Switch which also returns Accessor<JSX.Element> and tried the same here.

alfonsogarciacaro commented 1 year ago

Yes, covering all the possibilities is tricky because Solid API is very dynamic. I'm trying to cover the (I hope) 90% of use cases when interacting and prioritize making a nice F# API.

U2 types are not veery ergonomic and I try to avoid them when possible. In this case you can use an overload or just fallback: JSX.ElementType which at the end is obj so it accepts anything.

obeavers commented 1 year ago

Hey @alfonsogarciacaro, is this something you've had a chance to take a stab at?

alfonsogarciacaro commented 1 year ago

Hi there! Sorry, there were some issues with Fable and dotnet 7 and had to fix those first.

I've published a new version with ErrorBoundary, context and createRoot. There are examples for the first two in the sample app Counter page. I haven't tested createRoot but hopefully it should work.

When a curried function from a binding receives another function as argument, this causes problems with Fable uncurrying feature in some APIs I have to use System.Action. In those cases, please use .Invoke() to call them.

obeavers commented 1 year ago

Thank you!

On Sat, Nov 26, 2022 at 8:51 AM, Alfonso Garcia-Caro < @.*** > wrote:

Hi there! Sorry, there were some issues with Fable and dotnet 7 and had to fix those first.

I've published a new version with ErrorBoundary, context and createRoot. There are examples for the first two in the sample app Counter page. I haven't tested createRoot but hopefully it should work.

When a curried function from a binding receives another function as argument, this causes problems with Fable uncurrying feature in some APIs I have to use System.Action. In those cases, please use .Invoke() to call them.

— Reply to this email directly, view it on GitHub ( https://github.com/fable-compiler/Fable.Solid/issues/11#issuecomment-1328008334 ) , or unsubscribe ( https://github.com/notifications/unsubscribe-auth/AHAUXOLMRT4FESPLHWEGD73WKHFRXANCNFSM6AAAAAAR4JYBCU ). You are receiving this because you commented. Message ID: <fable-compiler/Fable . Solid/issues/11/1328008334 @ github. com>