React hooks in react library giving Invalid hook call error

后端 未结 6 1587
灰色年华
灰色年华 2021-02-12 13:17

I create a react library using https://www.npmjs.com/package/create-react-library And successfully used it on other React project. But when I tried to use react hooks functiona

6条回答
  •  长情又很酷
    2021-02-12 13:41

    Add to your Components Library's package.json

    "peerDependencies": {
      "react": ""
    }
    

    so that your lib package will use the same react package as your main app. https://nodejs.org/es/blog/npm/peer-dependencies/

提交回复
热议问题