From e330795a7bdd6920f9a81753869ea9dba5256383 Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Sun, 2 Jan 2022 23:04:13 -0800 Subject: [PATCH] Reworking routes Signed-off-by: James Ketrenos --- public/index.html | 76 ++++++++++++++++++++++++++--------------------- src/App.js | 14 +++++---- src/history.js | 13 ++++---- 3 files changed, 56 insertions(+), 47 deletions(-) diff --git a/public/index.html b/public/index.html index c219e0b..aa069f2 100755 --- a/public/index.html +++ b/public/index.html @@ -1,35 +1,43 @@ - - - - - - - - - - - - - - - - -
- - - - + + + + + + + + + + + + + React App + + + +
+ + diff --git a/src/App.js b/src/App.js index e8e177e..33a415d 100755 --- a/src/App.js +++ b/src/App.js @@ -6,10 +6,10 @@ import 'core-js/features/number/is-nan'; /* App starts here */ import React from "react"; +import { BrowserRouter, Route, Routes } from "react-router-dom"; import Button from '@material-ui/core/Button'; import AppBar from '@material-ui/core/AppBar'; import Toolbar from '@material-ui/core/Toolbar'; -import { Router, Route } from "react-router-dom"; //import 'typeface-roboto'; @@ -22,6 +22,7 @@ function App() { if (base) { base = new URL(base).pathname; } + console.log(`Base: ${base}`); return ( @@ -30,10 +31,13 @@ function App() { - - - - + + + + + + + ); } diff --git a/src/history.js b/src/history.js index 75bbf83..648b7f6 100755 --- a/src/history.js +++ b/src/history.js @@ -1,17 +1,14 @@ import { createBrowserHistory } from 'history'; -/* // Run our app under the /base URL. -const history = createBrowserHistory(), +const history = createBrowserHistory({ + basename: process.env.PUBLIC_URL + }), push = history.push; + history.push = (path) => { const base = new URL(document.querySelector("base") ? document.querySelector("base").href : ""); push(base.pathname + path); }; -*/ -export default createBrowserHistory({ - basename: process.env.PUBLIC_URL -}); - -//export default history; \ No newline at end of file +export default history; \ No newline at end of file