React Hooks issues in React 16.7 TypeError: Object(…) is not a function

前端 未结 3 1746
耶瑟儿~
耶瑟儿~ 2020-12-11 02:08

I\'m running the latest version of React and I\'m getting this error I have a simple Component using React Hooks as you can see here :

import React, { useS         


        
3条回答
  •  爱一瞬间的悲伤
    2020-12-11 02:17

    I tried to use the following in package.json but do not work.

    "react": "16.7.0-alpha.2",
    "react-dom": "16.7.0-alpha.2",
    

    What worked is the following

    "react": "next",
    "react-dom": "next",
    

    EDIT

    React version v16.8.0 has Hooks inside. Use that.

提交回复
热议问题