developit / nextjs-preact-demo

Next.js 9.3 + Preact = 21kB
https://nextjs-preact.now.sh
384 stars 25 forks source link

The hot reloading works only with unnamed export default functions. #15

Closed yassinebridi closed 4 years ago

yassinebridi commented 4 years ago

The about components export it's function like this:

export default () => (
  <main>
    <h1>About us</h1>
  </main>
);

but if i try to use it with any of the other export style:

export default function About() {}

or

const About = () => {}
export default About;

the hot reloading doesn't work.

JoviDeCroock commented 4 years ago

This is the case for Next 9.4 because named components are picked up by react-refresh, since these are hot-accepted modules they won't reload and react-refresh won't know how to reload them.

This will be fixed when we merge https://github.com/developit/nextjs-preact-demo/pull/16

yassinebridi commented 4 years ago

I have used it, and it works for my case, thanks for your help @JoviDeCroock, i will close this for now.