Skip to content

Explain in Troubleshooting.md why "const anyModule = module as any;" doesn't work as expected #1560

@TobiasWehrum

Description

@TobiasWehrum

At https://github.com/gaearon/react-hot-loader/blob/master/docs/Troubleshooting.md, you say that

const anyModule = module as any;
if (anyModule.hot) {
  anyModule.hot.accept('./app', () => render(App));
}

will lead to full page reloads, but

if ((module as any).hot) {
  (module as any).hot.accept('./app', () => render(App));
}

will work. I am pretty confused by that, as I'd expect both to lead to the same result. Not understanding it makes it harder to remember too.

Could you maybe add to the document why it is behaving like this?

(Or if you don't have the time to do that at the moment, give me a hint here?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions