You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
letprivatecolorCircle=
FunctionComponent.Of(fun(props:{| Rank : int
Color : Color.Marker.ColorReferences
OnPick : int -> unit |})->
Button.button [ Button.OnClick(fun _ -> props.OnPick props.Rank)][ str props.Color.Name ],"ColorSelector", equalsButFunctions
)
Then if you have an HMR call triggered the component instance in the DOM will not be re-render and still have a reference to the old OnPick callback. OnPick callback is created using dispatch for example ChangeColor >> dispatch.
The reason, is we are ignoring functions when determining if we need to redraw it.
We had the same problem with LazyView coming from Elmish and wrote our own version of it source
The text was updated successfully, but these errors were encountered:
moduleHMR =lethot= HMR.``module``.hot
/// Normal structural F# comparison, but ignores top-level functions (e.g. Elmish dispatch)./// Can be used e.g. with the `FunctionComponent.Of` `memoizeWith` parameter.letequalsButFunctions(x:'a)(y:'a)= #if DEBUG
if hot.status()= HMR.Status.Apply thenfalseelse
Fable.React.Helpers.equalsButFunctions x y
#else
Fable.React.Helpers.equalsButFunctions
#endif
More thinking need to be done around the way to shadow the API and also if we need an inline call somewhere to make zero impact on production bundle size
Description
If you have a component like:
Then if you have an HMR call triggered the component instance in the DOM will not be re-render and still have a reference to the old
OnPick
callback.OnPick
callback is created usingdispatch
for exampleChangeColor >> dispatch
.The reason, is we are ignoring
functions
when determining if we need to redraw it.We had the same problem with
LazyView
coming from Elmish and wrote our own version of it sourceThe text was updated successfully, but these errors were encountered: