tried to make react router work, still WIP

This commit is contained in:
Karma Riuk 2022-10-20 09:05:43 +02:00
parent d4b582c7c8
commit 4e80933ea9
3 changed files with 36 additions and 6 deletions

View File

@ -1,5 +1,19 @@
import * as React from 'react' import * as React from "react";
import { createRoot } from 'react-dom/client' import { createRoot } from "react-dom/client";
import App from "./components/App" import App from "@components/App";
import ErrorPage from "@components/ErrorPage";
import { createBrowserRouter, RouterProvider, Route } from "react-router-dom";
createRoot(document.querySelector("#root")).render(<App />) const router = createBrowserRouter([
{
path: "/",
element: <App />,
errorElement: <ErrorPage />,
},
]);
createRoot(document.querySelector("#root")).render(
<React.StrictMode>
<RouterProvider router={router} />
</React.StrictMode>
);

12
src/scss/error.scss Normal file
View File

@ -0,0 +1,12 @@
main {
#error-page{
display: flex;
flex-direction: column;
width: 25vw;
height: 35vh;
justify-content: space-evenly;
align-items: center;
}
}

View File

@ -14,7 +14,11 @@ module.exports = (env, argv) => {
output: { output: {
filename: "[name].[contenthash:10].js", filename: "[name].[contenthash:10].js",
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, "dist"),
clean: true clean: true,
publicPath: '/'
},
devServer: {
historyApiFallback: true
}, },
module: { module: {
rules: [ rules: [
@ -68,4 +72,4 @@ module.exports = (env, argv) => {
chunkFilename: '[id].css' chunkFilename: '[id].css'
})]) })])
} }
} }