question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed using preact/compat with react-hot-reload and react-router

See original GitHub issue

Hi, I tried to migrate from react to preact, so installed preact: "^10.0.0-rc.0" and define alias of preact/compat inside webpack. I also have react-router-dom: "^5.0.1" installed. I set up react-hot-loader: "^4.9.0" as well. in case of production, everything works fine.(react-hot-loader not getting import) in case of development, I face Uncaught Error: Invariant failed: You should not use <Switch> outside a <Router> error.

I also installed preact: "^8.4.2" and preact-compat and changed my alias to preact-compat and everything worked fine.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
marvinhagemeistercommented, Aug 10, 2020

FYI: We now have an official HMR solution for Preact called prefresh. We recommend everyone switching over to use that 🎉

0reactions
alireza-mhcommented, Sep 9, 2019

@marvinhagemeister should this labeled as a bug?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Switching to Preact (from React)
Switching to Preact can be as easy as installing and aliasing preact-compat in for react and react-dom . This lets you continue writing...
Read more >
Hot Reload is not working in my React App
I was following a tutorial that used react-router-dom@5.1 . Nothing worked at all including both .env suggestions, the react-scripts suggestion, ...
Read more >
react-hot-loader
Start using react-hot-loader in your project by running `npm i ... React-hot-loader should work out of the box with preact-compat , but, in...
Read more >
Complete Intro to React
A two day workshop to learn React and the surrounding ecosystem.
Read more >
Introduction to Preact : A smaller, faster React alternative
Using preact -compat for compatibility between Preact and React ... This starts up a dev server with Hot Module Reloading(HMR) at ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found