How to Check and Update React on Windows?

Posted in /  

Sangeeta Gulia
Last updated on January 9, 2023

    ReactJS, or simply React , is a free and open-source Javascript library for creating interactive UIs based on components. Developed and maintained by Meta, the library forms a basis for the development of single-page applications, mobile apps, and server-rendered apps with the use of web development frameworks like Next.js.

    If you are a front-end developer, React might be an important technology in your web development arsenal. Many times, you use it for a long time and forget about updating it to the latest version. Every new release of React comes with bug fixes, security enhancements, and, sometimes, new features.

    So, if you are using the old React version, make sure to update it. But what if you don’t know which version you are using? Don’t worry! I have got you covered.

    This article aims at guiding you through checking your React version and updating it to the latest one on Windows.

    Let us get started!

    How to Check the React Version?

    There are two approaches to checking which React version you use on your Windows system. They are as follows:

    1. Command Prompt

    Go to the command prompt, type the following command, and press Enter.

    npm view react version

    You will get the current version of React.

    Check React version

    2. Using the package.json File

    Through this approach, you will know what the React version was while building a specific project.

    Open any of your React projects , and go to the package.json file.

    Package.json file

    Here, you can see on line no: 9 the version of React, i.e., 18.2.0.

    How to Update React on Windows?

    Now you know what the current version is. Let us now update to the latest version through the following steps.

    Step 1

    Go to the official website of ReactJS and check the latest version available. Since the latest release is 18.2.0, in our case, there is no need for any updation.

    However, if your current React version is lower than 18.2.0, follow the below steps.

    Step 2

    Open the command prompt on your Windows system, and enter the following command:

    npm update react

    Or,

    npm install --save react@latest

    These simple commands will work. To verify, follow the above-mentioned steps.

    But, in case you don’t want to have the latest release and use the specific previous release, you can do so.

    Let us say your current version is 18.2.0, and you want to use 16.0.0. To do so, type the following command on your command prompt and press Enter .

    npminstall--savereact@16.0.0

    Now, check it either via the command prompt or look into your package.json file, as shown below.

    Package.json file -1

    Conclusion

    Before hopping on to the latest version of React, you must always read the changelogs that contain all changes in the updates. If you find any change in the changelog that can impact your application, you must look into the code changes done by Meta before updating React.

    However, updates are necessary, as they fix a lot of bugs, enhance the security of your application, and introduce new features. So, it is better always to use the latest release of any library or framework .

    Were you able to check and update ReactJS on your Windows system with the help of this article? Do let us know in the comments section below.

    Happy coding!

    People are also reading:

    Leave a Comment on this Post

    0 Comments