Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
White blank pages in my react application after using the react-router-dom to link pages

I have been receiving white blank pages when trying to create multiple pages within my app and I have been using the router-dom to try and fix this but still can't understand why. Here is my code with Home and Navigation js being inside a components folder in the src directory and App.js just inside the src directory.

App.js

import React, { Component } from 'react';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import Home from './components/Home';
import Glazing from './components/Glazing';
import Navigation from './components/Navigation';
     
class App extends Component {
  render() {
    return (      
      <BrowserRouter>
        <div>
          <Navigation />
          <Route path="/" component={Home} exact/>
          <Route path="/glazing" component={Glazing}/>
        </div> 
      </BrowserRouter>
    );
  }
}
     
export default App;

Nav.js

import React from 'react';
import { NavLink } from 'react-router-dom';
 
const Navigation = () => {
  return (
    <div>
      <NavLink to="/">Home</NavLink>
      <NavLink to="/glazing">Glazing</NavLink>
    </div>
  );
}
 
export default Navigation;

Home.js

import React from "react";
import logo from '../logo.svg';
import './Home.css';
import "@fontsource/dm-sans";

function home() {
  return (
    <div className="Home">
      <header className="Home-header">
        <h1>EPC RATING PREDICTOR</h1> 
      </header>
      <button> GET STARTED</button>
    </div>
  );
}

export default Home;
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If you are using react-router-dom@6 then there are a couple things you need to address.

  1. The Switch component was replaced by the Routes component and all Route components must be wrapped/rendered directly by Routes, or another Route component in the case of nesting routes.
  2. The Route component API changed; gone are the component, and render and children function props, all replaced by a single element prop taking a ReactNode, a.k.a. JSX, value.

Example:

import { BrowserRouter, Routes, Route } from 'react-router-dom';
 
import Home from './components/Home';
import Glazing from './components/Glazing';
import Navigation from './components/Navigation';
 
class App extends Component {
  render() {
    return (      
      <BrowserRouter>
        <div>
          <Navigation />
          <Routes>
            <Route path="/" element={<Home />} />
            <Route path="/glazing" element={<Glazing />} />
          </Routes>
        </div> 
      </BrowserRouter>
    );
  }
}

See the Upgrading from v5 guide for other changes.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!