React porfolio the issue is when I'm swathing between pages, background loads but the rest won't until I refresh the page

Viewed 31

I cant figure out how to properly structure it I guess tried following the docs and my whole page won't show, only the page background color, but like this it works but I have to reload the page every time I switch to it I'm new to it so any help is appreciated

my-app/src/App.js

import { Routes, Route } from "react-router-dom";
import Home from "./components/Home";
import About from "./components/About";
import Contact from "./components/Contact";
import Layout from "./components/Layout";
import Portfolio from "./components/Portfolio";
import "./App.scss";

function App() {
  return (
    <>
      <Routes>
        <Route path="/" element={<Layout />}>
          <Route index element={<Home />} />
          <Route path="about" element={<About />} />
          <Route path="/contact" element={<Contact />} />
          <Route path="/portfolio" element={<Portfolio />} />
        </Route>
      </Routes>
    </>
  );
}

export default App;

my-app/src/index.js

import React from "react";
import ReactDOM from "react-dom";
import reportWebVitals from "./reportWebVitals";
import { BrowserRouter } from "react-router-dom";
import App from "./App";
import "./index.css";

ReactDOM.render(
  <React.StrictMode>
    <BrowserRouter>
      <App />
    </BrowserRouter>
    ,
  </React.StrictMode>,
  document.getElementById("root")
);

reportWebVitals();
0 Answers
Related