6

How To Update the React js project from 15.6 to 16.8? is there any Steps need to to be followed ?

adiga
  • 34,372
  • 9
  • 61
  • 83
gautham
  • 81
  • 1
  • 1
  • 3
  • 1
    You can read about the Updating React project to the latest version on the documentation page. [https://create-react-app.dev/docs/updating-to-new-releases/](https://create-react-app.dev/docs/updating-to-new-releases/) – Afia Nov 13 '19 at 06:11

4 Answers4

6

You will have to install the latest version that you want to upgrade to by running npm install --save react@^16.8.0 react-dom@^16.8.0 or this if you are using yarn: yarn add react@^16.8.0 react-dom@^16.8.0 then run npm update --save or in the case of yarn yarn update --save to get all packages that are dependent and the latest updates for all your packages.

sylvia
  • 73
  • 5
  • If you want to get the next major version automatically just do this: ```npm add react@^16.0.0 react-dom@^16.0.0``` then run the next command ```npm update --save``` – sylvia Nov 13 '19 at 06:28
  • 1
    its `yarn upgrade --save` – zamil Jan 27 '20 at 08:11
0

You can use npm update --save react to update to latest version of react in your current project.

Or use npm update --save react@[version] for specific version.

Ex :- npm update --save react@16.11. In your case npm update --save react@16.18

And if you want to use globly then use -g.

Ex:- npm update --save -g react@16.11

Shashwat Prakash
  • 434
  • 5
  • 14
0

there is 2 way, directly and indirectly

1.directly: bin this code in the import of your code

import update from 'react-update'

2.indirectly: in terminal use, this command for update the react to the last version , also if you install it again, it will install the last version of react.js (npm install --g create-react-app)

npm i --save react-update

0

you can use only two commands -

1 - npm install --save react@^16.8.0 react-dom@^16.8.0

2 - npm update --save

after that you can check your react version using the following commands -

npm view react version