React Hooks Error: Hooks can only be called inside the body of a function component

后端 未结 17 2140
旧巷少年郎
旧巷少年郎 2020-12-05 04:07

I am getting this error when using the useState hook. I have this in it\'s basic form, looking at the react docs for a reference, but am still getting this erro

17条回答
  •  没有蜡笔的小新
    2020-12-05 04:24

    I experienced this error while using Parcel's Hot Module Replacement, and fixed by updating react-dom to it's alpha version:

    yarn add react-dom@16.7.0-alpha.0
    

    See this issue.

提交回复
热议问题