怎么升级 react 版本? 下面本篇文章就来给大家介绍一下. 有一定的参考价值, 有需要的朋友可以参考一下, 希望对大家有所帮助.
升级 react 版本的方法:
前提条件:
1, 查看 react 版本
当前开发项目的 react 版本从哪里看呢? 其实就在 package.JSON 文件中, 你搜索 "react", 即可看到版本号:
- {
- "name": "XXX",
- "version": "1.0.0",
- "description": "",
- "main": "index.js",
- "scripts": {
- "test": "echo \"Error: no test specified\"&& exit 1"
- },
- "author": "",
- "license": "ISC",
- "dependencies": {
- "react": "^16.12.0"
- }
- }
或者, 输入命令 NPM info react 查看最新的 react 版本
- license: 'MIT',
- keywords: [ 'react' ],
- version: '16.12.0',
- main: 'index.js',
- engines: { node: '>=0.10.0' },
- dependencies:
- { 'loose-envify': '^1.1.0',
- 'object-assign': '^4.1.1',
- 'prop-types': '^15.6.2' },
- browserify: { transform: [ 'loose-envify' ] },
找到 version 可以看见最新版本是 16.12.0
2, 升级 react 版本
升级到指定的 react 版本
NPM install react@版本号
例: 升级到 16.8.6 版本
NPM install react@16.8.6 --save
更多 web 开发 https://www.html.cn/ 知识, 请查阅 HTML 中文网 !!
来源: http://www.css88.com/qa/react/16388.html