How to use new Feature Hooks in React?

前端 未结 1 478
南笙
南笙 2020-12-06 09:59

I just read about the react\'s new feature hooks.Read about hooks but i can\'t able to use it. it gives me error.

I am currently using version 16.6.0

Finally

相关标签:
1条回答
  • EDIT:

    Hooks are released as a part of version 16.8.0 and you can use it by installing React and React-dom 16.8.0

    run

    yarn install react@16.8.0 react-dom@16.8.0
    

    to install. In order to upgrade react to latest version

    yarn upgrade react react-dom
    

    Hooks aren't present in version 16.6.0, but are a proposal for version 16.7.0. You can however use 16.7.0-alpha.0 alpha version of React to test them

    In order to use this install the above version using

    yarn add react@next react-dom@next
    

    Make sure that you install both react and react-dom or else your would get warning like

    TypeError: Object(…) is not a function” error when trying to use react hooks (alpha)

    0 讨论(0)
提交回复
热议问题