Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the location of the Browser.Navigation.Key in the model has changed #55

Open
atomkirk opened this issue May 29, 2021 · 1 comment
Open

Comments

@atomkirk
Copy link

I don't understand what this error means:

[elm-hot] Hot-swapping Main not possible: the location of the Browser.Navigation.Key in the model has changed.

would you mind helping me understand how to fix?

@mkaszas
Copy link

mkaszas commented Jul 1, 2021

I realise this might be late, but I just had this problem and decided to make my findings visible to anyone facing this issue later.

If you make sure not to copy your navKey to a different place in your model, this should work.

I had this in my top-level module:

type Model
    = Error String
    | Loading Url Nav.Key
    | Running Url Nav.Key App.Model

So when switching between Loading & Running states, I needed to copy the navKey from one place to another. For some reason this stops elm-hot from being able to apply changes.

To fix this, you can make sure the navKey is stored in one place and never changes:

In my example above, this is how this could be achieved:

type alias Model =
    { navKey : Nav.Key
    , url : Url
    , state : State
    }

type State
    = Error String
    | Loading
    | Running App.Model

I hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants