Skip to content

Commit

Permalink
fix(react): fix some upgrade issues and rename public to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mborne committed Nov 19, 2023
1 parent e4a2158 commit f687eac
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 61 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 MBorne
Copyright (c) 2021 MBorne

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ For the moment, it looks like a scam which served to motivate a child to learn h
| Name | Description |
| -------------- | ----------- |
| Addition | `a + b = ?` |
| Substraction | `a - b = ?` |
| Soustraction | `a - b = ?` |
| Multiplication | `a * b = ?` |
| Double | `2 * a = ?` |
| Moitié | `a / 2 = ?` |
Expand Down
File renamed without changes.
File renamed without changes.
64 changes: 64 additions & 0 deletions docs/js/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@mborne/math-city",
"version": "0.1.0",
"description": "",
"description": "Play smart games to earn money to build your city and protect it from zombies!",
"main": "index.js",
"scripts": {
"build": "webpack --mode=production",
Expand All @@ -10,10 +10,10 @@
},
"repository": {
"type": "git",
"url": "https://gogs.quadtreeworld.net/experiments/math-city.git"
"url": "https://github.com/mborne/math-city.git"
},
"author": "",
"license": "UNLICENSED",
"author": "MBorne <mborne@users.noreply.github.com>",
"license": "MIT",
"private": true,
"devDependencies": {
"@babel/core": "^7.23.3",
Expand Down
38 changes: 0 additions & 38 deletions public/js/main.js

This file was deleted.

2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const express = require('express');
const app = express();
const port = 3000;

app.use(express.static('public'));
app.use(express.static('docs'));

app.get('*', function (req, res) {
res.redirect('/');
Expand Down
2 changes: 1 addition & 1 deletion src/components/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Home extends React.Component {
modeItems.push(modeItem);
});
return (
<div class="home">
<div className="home">
<h1>MathCity</h1>
<ul className="list-group">
{modeItems}
Expand Down
12 changes: 6 additions & 6 deletions src/components/Main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import {
HashRouter as Router,
Switch,
BrowserRouter as Router,
Routes,
Route,
useParams
} from 'react-router-dom';
Expand All @@ -29,10 +29,10 @@ class Main extends React.Component {
render() {
return (
<Router>
<Switch>
<Route exact path="/" component={Home} />
<Route path="/play/:mode" children={<GameRoute />}/>
</Switch>
<Routes>
<Route exact path="/" element={<Home />} />
<Route path="/play/:mode" element={<GameRoute />}/>
</Routes>
</Router>
);
}
Expand Down
11 changes: 4 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ const React = require('react');
const ReactDOM = require('react-dom');

import Main from './components/Main';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import { createRoot } from 'react-dom/client';

ReactDOM.render(
<BrowserRouter>
<Main />
</BrowserRouter>,
document.getElementById('main')
);
const container = document.getElementById('main');
const root = createRoot(container);
root.render(<Main />);
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
entry: './src/index.js',
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'public/js'),
path: path.resolve(__dirname, 'docs/js'),
},
module: {
rules: [{
Expand Down

0 comments on commit f687eac

Please sign in to comment.