vuejs-templates / webpack

A full-featured Webpack + vue-loader setup with hot reload, linting, testing & css extraction.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

White blank screen using React Router

onlyfortestweb opened this issue · comments

I am use React Router for my web app, it will build successful but its just show blank white screen. Any body help to fix it.
App.js

import React, { Component } from 'react';
import { BrowserRouter as Router, Route } from 'react-router-dom';
import './App.css';
import Home from './Pages/Home.jsx';

class App extends Component {
  render() {
    return (
      <Router>
        <div>
          <Route exact path="/" Component={Home}/>
        </div>
      </Router>
    );
  }
}

export default App;

Home.jsx Code

import React, { Component } from 'react';


class Home extends Component{
    render(){
        return(
            <div>
                <h2>Welcome</h2>
                <p>xc.b nldfgjkln ;fngd golnldf ng</p>
            </div>
        );
    }
}

export default Home;

Have you found a solution for this issue? I am also having the same propbelm. It works perfectly If I am not using router components

I see typeo in App.js
<Route exact path="/" Component={Home}/>
// it should be component(small)

am facing the same problem
any solution?

use this:


import {BrowserRouter as Router, Route, Routes} from "react-router-dom";

<Routes>
  <Route exact path="/" element={<Home/>} />
</Routes>

Thanks this helped me.
I used element instead of component.

I am having the same problem. I used the same import but still nothing.

Please I need help with this also

i think the problem is arrising from components itself , i am using a arrow function export component changed to simple rfc

Have you found a solution for this issue? I am also having the same propbelm. It works perfectly If I am not using router components

I uninstalled the current version and installed the old one by using this command
npm install react-router-dom@5
and things were solved.. dont have to use routes in the place of switch , can add multiple element components in one tag..

try updating npm also

latest

try updating npm also

the latest react router dom is unstable.. the prev version works fine

Something should be done about this, no solution works. People's futures depend on things like this. Doing a Mern stack project to apply for a job and all I am seeing is blank pages

Guys, If you really wanna fix this. The only way is this. Install the old version 😄

Below Link is working fine this is the router version issue , problem will resolve after follow below link instruction with latest Router version.

https://stackoverflow.com/questions/71972523/navlink-link-from-react-router-dom-not-working-blank-screen/71992282#71992282

Thanks
Regards
Rameez Jaffri

commented

import React from "react";
import ReactDOM from "react-dom/client";
import { BrowserRouter } from "react-router-dom";

import "./index.css";
import App from "./App";

ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>



</React.StrictMode>
);

do this in index.js