Server render + react hooks problem

I use meteor server-render package with react hooks components. Everything is fine when I try to render the pages one by one. But when I try to render many pages at the same time, I see the problem.

You can try by just view source of the webpage and press f5 button fast enough.

W20190807-11:55:58.273(7)? (STDERR) { Invariant Violation: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
W20190807-11:55:58.274(7)? (STDERR) 1. You might have mismatching versions of React and the renderer (such as React DOM)
W20190807-11:55:58.275(7)? (STDERR) 2. You might be breaking the Rules of Hooks
W20190807-11:55:58.285(7)? (STDERR) 3. You might have more than one copy of React in the same app
W20190807-11:55:58.285(7)? (STDERR) See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.
W20190807-11:55:58.285(7)? (STDERR)     at invariant (/badass-directory/node_modules/react-dom/cjs/react-dom-server.node.development.js:58:15)
W20190807-11:55:58.285(7)? (STDERR)     at resolveCurrentlyRenderingComponent (/badass-directory/node_modules/react-dom/cjs/react-dom-server.node.development.js:953:45)
W20190807-11:55:58.286(7)? (STDERR)     at useReducer (/badass-directory/node_modules/react-dom/cjs/react-dom-server.node.development.js:1109:33)
W20190807-11:55:58.286(7)? (STDERR)     at Object.useState (/badass-directory/node_modules/react-dom/cjs/react-dom-server.node.development.js:1098:10)
W20190807-11:55:58.286(7)? (STDERR)     at useState (/badass-directory/node_modules/react/cjs/react.development.js:1462:21)
W20190807-11:55:58.286(7)? (STDERR)     at SellPostsByUser (imports/ui/components/details/sell-posts-by-user.js:54:27)
W20190807-11:55:58.286(7)? (STDERR)     at processChild (/badass-directory/node_modules/react-dom/cjs/react-dom-server.node.development.js:2888:14)
W20190807-11:55:58.286(7)? (STDERR)     at resolve (/badass-directory/node_modules/react-dom/cjs/react-dom-server.node.development.js:2812:5)
W20190807-11:55:58.286(7)? (STDERR)     at ReactDOMServerRenderer.render (/badass-directory/node_modules/react-dom/cjs/react-dom-server.node.development.js:3202:22)
W20190807-11:55:58.286(7)? (STDERR)     at ReactDOMServerRenderer.read (/badass-directory/node_modules/react-dom/cjs/react-dom-server.node.development.js:3161:29)
W20190807-11:55:58.287(7)? (STDERR)     at renderToString (/badass-directory/node_modules/react-dom/cjs/react-dom-server.node.development.js:3646:27)
W20190807-11:55:58.287(7)? (STDERR)     at Promise.asyncApply (imports/startup/server/ssr-init.js:50:12)
W20190807-11:55:58.287(7)? (STDERR)     at /home/minhna/.meteor/packages/promise/.0.11.2.guzdz5.ulzrm++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/meteor-promise/fiber_pool.js:43:40 name: 'Invariant Violation', framesToPop: 1 }

@minhna we are experiencing this now in SSR in production.

Were you able to find a fix?

Not really, I tried to add this.unblock(); to the methods and implement caching system. It helps alot.

1 Like

We are facing this error after upgrading meteor to 2.1.
Server is running repeatedly.

try upgrading to 2.1.4 or 2.2.2.

Edit: Yes, I’m talking about react-meteor-data:

meteor update react-meteor-data
1 Like

Are they MeteorJS versions?
// edit: I think you’re talking about react-meteor-data package

2 Likes

react-meteor-data version is already 2.2.2.
:frowning_face: