How to fix legacy context-API issue in react application with a single line of code

Hey there, have you been working on a react project and experiencing the error below

legacyScreenshot.png

This kind of error mostly occurs when you are getting data from a server or when your React Application package is not the latest version. Here is a simple solution to the error in 2 steps:

  1. First go to your index.js file(if you are using react with create-react-app, the index.js file would be in the src folder)
  2. It should look like the image below

indexJS .png

  1. Now if you are here, all you need to do is to change the React.StrictMode to React.Fragment on line 8 and 10. It should look like this

newIndex.png With this the error in the console code would be resolved