fable-compiler / fable-compiler.github.io

Fable web site
https://fable.io
23 stars 64 forks source link

Incorrect information about limitation for React Fast Refresh on "Elmish Components with Elmish 4 and UseElmish" #147

Closed MangelMaxime closed 1 year ago

MangelMaxime commented 1 year ago

In order for React Fast Refresh to work, files must include only one JS export. This means you should only expose one functional component (decorated with Feliz.ReactComponent or JSX.Component) and the rest of the code in the file must be private.

@alfonsogarciacaro

I think the "files must include only one JS export" is incorrect.

At least when using Feliz + Feliz.UseElmish, you can have several exports.

From my tests and understanding, the limitation for React Fast Refresh is that only ReactComponents should be exposed from the module.

So you can do stuff like:

type Components with

    [<ReactComponent>]
    static member AnErrorOccured = // ...

    [<ReactComponent>]
    static member AnErrorOccured(title: string, subtitle: string) = // ...

Example taken from Fable.Packages.

alfonsogarciacaro commented 1 year ago

Oh, you're right! Didn't notice that 😅 I corrected it, thanks for pointing it out!