React js-How I solved the errors ?
React JS makes Javascript coding easier as it is extremely competent and easy to adopt. React is gaining popularity across the community. It is an open source, frontend library responsible only for the view layer of application.
→ Currently I built an Amazon clone by using React Js for the first time .The experience and the process was too smooth and understable ! It really amazed me. I used the latest version of REACT 17.0.2 .
Even if it’s easy to use , but beginners might face errors that I came through .
Listing some of the errors I faced :
- After installing React using npx-create-react-app “name “. To add pages in your application , install react router dom :
Here, version of react-router-dom is important to check .You might need same version , but if you face error by doing that like I did, You can install :
npm install react-router-dom@5.3.0
This works perfectly .
2. Add this in your app.js file now
import { BrowserRouter as Router, Route, Switch } from “react-router-dom”;
These are the components you need to add
Router {Switch{ Route path= “ ”{Add your page here }}}
Here, You can face the error of Switch not valid , because sometimes the version may not support the Component “switch” as it is replaced by “Routes”.
So, just replace the word switch by Routes .
3. While in process of building of the application, the page can sometimes become un-responsive .
Here, first check the errors listed in the terminal and rectify them. If the terminal is not showing any errors, then you need to check the console of the web page by right clicking on the page and select inspect element. Errors will listed there .Solve them by just asking someone or searching it on google. This will not waste your time.
This is my un-responsive page , errors are listed there . As soon as I solve them, the original page will be reloaded.
These were some issues I faced. I will keep updating as i find more errors and solutions in React.
Thanks for reading !