Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

109
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda