elmish / hmr

Hot Module Replacement for Elmish apps
https://elmish.github.io/hmr
Other
28 stars 9 forks source link

HMR breaks the whole app after dispatching any message #25

Closed Zaid-Ajaj closed 5 years ago

Zaid-Ajaj commented 5 years ago

Description

On the initial load, HMR works properly and I am able to make changes on the fly:

hmr-working

but after dispatching any message, the whole dispatch loop is frozen and the application stops working

hmr-not-working

Repro code

To reproduce the bug, I made a repo elmish-hmr-bug, follow the steps:

Expected and actual results

Expected HMR to work after dispatching a message.

Related information

  <ItemGroup>
    <PackageReference Include="Fable.Elmish.HMR" Version="4.0.0" />
    <PackageReference Include="Fable.Elmish.React" Version="3.0.1" />
  </ItemGroup>
MangelMaxime commented 5 years ago

Hum so the problem is that when triggering HMR, the view rendered/accessible is the old one.

So when you click you are clicking in the old program instance which is marked as Inactive. I need to understand why the view from the new program instance is not rendered to take precedence over the old view.

MangelMaxime commented 5 years ago

It should be fixed in Elmish.HMR 4.0.1

The problem was because we had open Elmish.React at the top of the file. Then when shadowing Elmish.React API we were using the LazyView from Elmish.React instead of the one from Elmish.HMR which knows when to force a rendering. :)

Zaid-Ajaj commented 5 years ago

You are awesome @MangelMaxime I just tested it and works really nice! thanks a lot