Open MangelMaxime opened 5 years ago
It seems like this code should do the job:
module HMR =
let hot = 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.
let equalsButFunctions (x: 'a) (y: 'a) =
#if DEBUG
if hot.status() = HMR.Status.Apply then
false
else
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 source