Skip to content

Bug: I can't get react-refresh to work unless I enable React Development Tools #19727

@leidegre

Description

@leidegre

React version: 16.13.1

Steps To Reproduce

  1. Use <script defer /> to fetch react and react-dom from CDN
  2. Wait for DOMContentLoaded event
  3. Call injectIntoGlobalHook from react-refresh/runtime before first ReactDOM.render
  4. Touch some module which has hot reloading enabled
  5. Watch in despair as nothing happens 😢
  6. Enable React Development Tools
  7. Touch some module which has hot reloading enabled (again)
  8. Watch in awe as things update in real-time 🥇

Originally I just posed this as a question to @gaearon whether this behavior was by design, i.e. that the react-refresh code actually needed the React Development Tools but I'm presuming no?

I stepped through the code and noticed that when performReactRefresh ran, the collections helpersByRendererID, failedRootsSnapshot and mountedRootsSnapshot we're all empty. As soon as I enabled React Development Tools things started working. So what did I miss?

I can try to repo this if necessary but I'm using my own bundler that is using some proprietary stuff so I would like to use that as a last resort. There's gotta be some basic stuff that I haven't considered...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions