daily log 12.20.20
TIL:
Reverse an array:
myArray.map((val, index, array) => array[array.length - 1 - index]);
Today, this error
reactjs - Create-React-App build - "Uncaught SyntaxError: Unexpected token <" - Stack Overflow
was caused by the homepage:
line in package json. Solved by simply deleting that line.
REACT HEROKU EXPRESS PARTY
yarn add express
- In the same directory as your package json, make a
server/server.js
- Update package json start script from
"start": "react-scripts start"
(use this for dev still) to"start": "node server/server.js"
- Remove package json homepage field at the bottom
"homepage": "https://aaroncaraway.github.io/umre-todo/"
SCRIPT.JS
const path = require('path');
const express = require('express');
const app = express();
const publicPath = path.join(__dirname, '../build');
const port = process.env.PORT || 5000;
app.use(express.static(publicPath));
app.get('*', (req, res) => {
res.sendFile(path.join(publicPath, 'index.html'));
});
app.listen(port, () => {
console.log('Server is up!');
});
To help me search for this next time
heroku react react heroku deploy react heroku heroku deploy react react on heroku