React: Invariant Violation: Minified React error #307

Created on 4 Mar 2019  ·  5Comments  ·  Source: facebook/react

I am getting below error when try host app with production build, I have used new React Hooks.

Invariant Violation: Minified React error #307; visit https://reactjs.org/docs/error-decoder.html?invariant=307 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.

Most helpful comment

Have you tried following the links? Hope this helps.

clicking on a link

All 5 comments

Follow these may help you in chasing the error root cause out: https://reactjs.org/warnings/invalid-hook-call-warning.html

Have you tried following the links? Hope this helps.

clicking on a link

(The final URL that describes possible causes is: https://reactjs.org/warnings/invalid-hook-call-warning.html)

一般是因为你的项目的react版本,低于使用的第三方库依赖的react的版本造成的,可以将工作项目的react版本升级,或降低依赖库的react版本。

The reason maybe you use multi react version, you should ensure your project code use the react version is more than other library react version.

i have did as your said, just like . " aside of making React and react-dom peer deependencies in your libraries package.json, you also should mark them as 'externals' when building them with webpack"
but the #321 still exist,who can help me.

"peerDependencies": {
    "antd": "^3.25.0",
    "styled-components": "^4.4.1",
    "react": "^16.11.0",
    "react-dom": "^16.11.0"
  }
 externals: [
    // nodeExternals(),
    {
      react: {
        root: 'React',
        commonjs2: 'react',
        commonjs: 'react',
        amd: 'react'
      },
      'react-dom': {
        root: 'ReactDOM',
        commonjs2: 'react-dom',
        commonjs: 'react-dom',
        amd: 'react-dom'
      }
    }
}

if i don't use useCallback ant useMemo ,it can work,but i need useMemo...

Was this page helpful?
0 / 5 - 0 ratings