2

I'm new to React and I'm creating a React app which on npm start it's returning a blank page. Below is :

Here's my index.js

import React from "react";
import ReactDOM from 'react-dom';

import App from '../src/App';

ReactDOM.render(<App />, 
document.getElementById('root'));

App.js

import React from 'react'
import { BrowserRouter as Router, Switch, Route 
} from 'react-router-dom';

const App = () => {
  return (
      <div>
        Ecommerce  
      </div>
  )
}

export default App;

How do I fix this?

Drew Reese
  • 165,259
  • 14
  • 153
  • 181
Riziki
  • 51
  • 1
  • 5
  • Open browser dev tools and see if there are any errors displayed in the console. – tromgy Jan 17 '22 at 21:08
  • Audit usage of navigator.userAgent, navigator.appVersion, and navigator.platform is the error I'm getting – Riziki Jan 17 '22 at 21:13
  • You are not even using anything from `react-router-dom` so regardless of whether or not it's installed is irrelevant, other than you'd likely see some import errors. I don't see any issues in the code you've shared and see no reason why it wouldn't render the `div` element with "Ecommerce" text. Do you have any error messages in your console? – Drew Reese Jan 17 '22 at 23:33
  • I managed to fix this. Was missing a few dependencies that were needed . – Riziki Feb 04 '22 at 10:25
  • sometimes is cache, just re start pc – nativelectronic Feb 02 '23 at 01:42

2 Answers2

1

Make sure you have installed react-router-dom:

npm i react-router-dom
0

I had this problem until just now I turned off my VPN.

  • Turn off VPN
  • restart your app (npm start)
  • let us know if it works
bear
  • 1,318
  • 5
  • 16
  • 26