That's a great blog post, great job! However, It didn't work for me at the very end =/
I got this error:
Hash: 421850953aa4087426ac Version: webpack 4.41.5 Time: 115ms Built at: 04/02/2021 7:24:23 PM Asset Size Chunks Chunk Names ../favicon.ico 1.23 KiB [emitted] ../images/phoenix.png 13.6 KiB [emitted] ../robots.txt 202 bytes [emitted] app.js 4.57 KiB app [emitted] app Entrypoint app = app.js [0] multi ./js/app.js 28 bytes {app} [built] [./js/app.js] 356 bytes {app} [built] [failed] [1 error] ERROR in ./js/app.js 25:16 Module parse failed: Unexpected token (25:16) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders | const greeting = document.getElementById("root"); | > ReactDOM.render(<Greeter name="Phoenix" />, greeting); | | @ multi ./js/app.js app[0]
I believe it's because of the <Greeter which is React code in the app.js file.
<Greeter
app.js
I fixed it by moving the typescript/react code to a index.tsx file and then importing it inside the app.js file.
index.tsx
import React from "react"; import ReactDOM from "react-dom"; import Greeter from "./hello"; const greeting = document.getElementById("root"); ReactDOM.render(<Greeter name="Phoenix" />, greeting);
const _css = require("../css/app.scss"); import "./index";
This is how I fixed in case other people also face this error.
I also got another error, but I fixed by commenting out the "module": "ESNext" line of my tsconfig.json 👍
"module": "ESNext"
tsconfig.json
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
That's a great blog post, great job! However, It didn't work for me at the very end =/
I got this error:
I believe it's because of the
<Greeter
which is React code in theapp.js
file.I fixed it by moving the typescript/react code to a
index.tsx
file and then importing it inside theapp.js
file.assets/js/index.tsx
assets/js/app.js
This is how I fixed in case other people also face this error.
I also got another error, but I fixed by commenting out the
"module": "ESNext"
line of mytsconfig.json
👍