โจ React 17 and React Scripts 4 | A Walkthrough

I am a full stack developer, YouTuber and blogger!
Search for a command to run...

I am a full stack developer, YouTuber and blogger!
This is helpful, thanks for sharing. Max Programming.
This page is broken due to the Youtube embed. Use the official syntax for embed videos, Hashnode will take care of responsiveness. Eg:
%[youtube video link]
Thanks for the suggestion Emily. Appreciate that ๐
Hey all ๐๐ Webhooks are a powerful tool that allow applications to communicate with each other in real-time. They are often used to send notifications or updates from one system to another without requiring manual intervention. If you know the bas...

Hey everyone! It's been a while since I wrote my last article. But here I am with another topic that might be informational to you ๐. This time I am writing about why you should avoid the onclick attribute in your HTML and JavaScript code. This ar...

โ What and Why Memoriez โ This is a very important question because it makes things clear as to why this app is needed. I built Memoriez because I honestly found it hard to write and maintain journal/diary entries daily. It's not easy to maintain a j...

Explained with a simple project

๐ Hey developers! This post is about how you can sort import statements in your JavaScript/TypeScript/React/Node etc projects easily with Prettier in VS Code when you format the code. https://www.youtube.com/watch?v=QQWgN0_gUxI What will you achieve...

So React 17 and React Scripts 4 are successfully released. Actually React 17 was released with no new features. But then we got something called JSX Transform from React 17 and New Hot Reload from React Scripts 4. So let's cover those in this one.
create-react-app app to use React 17.First off, open your package.json file in your project and change the react, react-dom and react-scripts versions as shown below ๐

Then run npm i or yarn as per the package manager you are using to install those updated versions.
Once you have updated to React 17 and React Scripts 4, you will use JSX Transform, and for that, you will have to edit all the files, which is not a programmer does ๐.
There is a simple script provided by React, which will remove all of your React imports from your components.
npx react-codemod update-react-imports
Run this script inside of your folder in the CLI,
If you are getting any errors running this command above, it's because you have not committed your git changes, you can put a
--forceto force it to do that
This is the 1st question you will get after running that command
You can select the (.) folder and press enter because you want it to do in the current directory.

The next question would be that which type of JavaScript are you using in your project, you can select the one you are using

Once every question is complete, it'll do it's job and remove the React imports from all the components

This is not specifically a setting to enable but it is rather a feature by create-react-app. In your cra apps, you will find that when you save your code and check the browser, it won't refresh and will make changes instantly
You can check how it works on this video
create-react-appWith React Scripts version 4, you no longer have the serviceWorker.js file which you had in the earlier versions of React Scripts. It is removed now and will not work even if you have the file, it will fail at build time.
There is a new thing called reportWebVitals.js which helps you check the performace of your app. Learn more
I also have a video on YouTube about React 17 and React Scripts 4
Finally, Give the post a ๐ like if you liked it, and don't hesitate to ask questions and give suggestions in the ๐ฌ comments. Thanks for reading ๐