When using react hooks such as useState, the SSR will crash with the following error:
{ 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:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.
at invariant (<anonymous>:58502:15)
at resolveDispatcher (<anonymous>:59850:28)
at useState (<anonymous>:59875:20)
at Hook (<anonymous>:517:31)
at processChild (/PATH/TO/PROJECT/node_modules/react-dom/cjs/react-dom-server.node.development.js:2888:14)
at resolve (/PATH/TO/PROJECT/node_modules/react-dom/cjs/react-dom-server.node.development.js:2812:5)
at ReactDOMServerRenderer.render (/PATH/TO/PROJECT/node_modules/react-dom/cjs/react-dom-server.node.development.js:3202:22)
at ReactDOMServerRenderer.read (/PATH/TO/PROJECT/node_modules/react-dom/cjs/react-dom-server.node.development.js:3161:29)
at Object.renderToString (/PATH/TO/PROJECT/node_modules/react-dom/cjs/react-dom-server.node.development.js:3646:27)
at Object.render (/PATH/TO/PROJECT/node_modules/@seagull/pages/dist/src/render.js:7:14)
at renderUMD (/PATH/TO/PROJECT/node_modules/@seagull/routes/dist/src/RouteContext.js:50:24)
at LazyRouteContext.render (/PATH/TO/PROJECT/node_modules/@seagull/routes/dist/src/RouteContext.js:40:22)
at LazyRouteContext.render (/PATH/TO/PROJECT/dist/runner.js:38:13)
at <anonymous> name: 'Invariant Violation', framesToPop: 1 }
I suspect it's 1, as currently the versions of react (16.8.1) and react-dom (16.6.0) inside seagull/pages don't match.
Steps to reproduce
Create a component with hooks such as
import * as React from 'react'
export default function HookTest() {
const [count, setCount] = React.useState(0)
const increase = () => setCount(count + 1)
return <button onClick={increase}>{count}</button>
}
When using react hooks such as
useState
, the SSR will crash with the following error:I suspect it's 1, as currently the versions of react (16.8.1) and react-dom (16.6.0) inside seagull/pages don't match.
Steps to reproduce