使用 Hook 需要更新到 react@16.7.0-alpha.2
如果想要使用 react 的 Hook 属性,需要更新 react 的版本到 16.7.0-alpha.0
+ 的版本,否则会直接报错。
如果使用 create-react-app
套件,这里直接给一份 package.json
,直接更新就行:
因为我手动安装更新的时候发现在 terminal 上选择完版本后,无法安装,会卡住,即使搭梯子一样会被卡住
{
"name": "new",
"version": "1.0.0",
"description": "",
"keywords": [],
"main": "src/index.js",
"dependencies": {
"react": "16.7.0-alpha.0",
"react-dom": "16.7.0-alpha.0",
"react-scripts": "2.1.1"
},
"devDependencies": {},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
文章已经结束啦
文章版权:Postbird-There I am , in the world more exciting!
本文链接:http://www.ptbird.cn/react-hook-update-raect-16-7-0-alpha-2.html
转载请注明文章原始出处 !
扫描二维码,在手机阅读!