react-refresh-webpack-plugin icon indicating copy to clipboard operation
react-refresh-webpack-plugin copied to clipboard

Plugin seems to not like working in SSR

Open mvittiglio opened this issue 2 years ago • 6 comments

While the page refreshes automatically as expected, if I am in need of refreshing the page (or opening a new page even) the page will error out complaining of even the smallest change (just text, for example).

Warning: Text content did not match. Server: "Hello, dude! Click count: " Client: "Hello, fella! Click count: "
    at h1
    at div
    at HelloWorld (http://localhost:3000/dist/bundle.js:3996:66)
    at Router (http://localhost:3000/dist/bundle.js:42092:15)
    at BrowserRouter (http://localhost:3000/dist/bundle.js:40322:5)
    at App
node_modules/react-dom/cjs/react-dom.development.js:86
Warning: An error occurred during hydration. The server HTML was replaced with client content in <div>.

Is this plugin incompatible with SSR methodologies?

mvittiglio avatar Nov 18 '22 17:11 mvittiglio

any fix? same issue

childrentime avatar Dec 04 '22 12:12 childrentime

Everything works. I added the plugin to the Webpack for both the client and the server config to make it work.

Kallenju avatar Dec 06 '22 14:12 Kallenju

@Kallenju can you give a simple repo example?

childrentime avatar Dec 06 '22 15:12 childrentime

@Kallenju can you give a simple repo example?

Of course. But, I want to warn you that I am a noob in React.

https://github.com/Kallenju/template-for-react-ts-ssr-hmr

For start:

npm install

npm run dev

React component in './src/shared/Header.tsx'

Kallenju avatar Dec 06 '22 15:12 Kallenju

thanks! It seems to work well. I think my mistake was caused by I do not restart nodejs server.

childrentime avatar Dec 06 '22 16:12 childrentime

I have a template repo as well with SSR: https://github.com/adbutterfield/fast-refresh-express

adbutterfield avatar Mar 17 '23 13:03 adbutterfield