I’m encountering (Uncaught Error: Module build failed: SyntaxError: Unexpected token) which appears to be caused by the usage of the spread operator (…prevMeme) in your JSX code, which is not being properly transpiled by Babel. I’m using React 17.0.2 and should have the latest version of Babel but somehow it still failed to build.
Here’s my use of the spread operator:
Meme.js
I have tried to install all the latest packages of Babel that should be compatible with my project. Here’s my package.json:
package.json
And here’s my webpack.config.js:
webpack.config.js:
When I try to access the application in the browser I get this error:
index.pack.js:517 Uncaught Error: Module build failed: SyntaxError: Unexpected token (34:12)
[0m [90m 32 | [39m [36mconst[39m url [33m=[39m allMemes[randomNumber][33m.[39murl
[90m 33 | [39m setMeme(prevMeme [33m=>[39m ({
[31m[1m>[22m[39m[90m 34 | [39m [33m...[39mprevMeme[33m,[39m
[90m | [39m [31m[1m^[22m[39m
[90m 35 | [39m randomImage[33m:[39m url
[90m 36 | [39m }))
[90m 37 | [39m }[0m
at Object.<anonymous> (index.pack.js:517:7)
at __webpack_require__ (index.pack.js:20:30)
at Object.<anonymous> (index.pack.js:406:13)
at __webpack_require__ (index.pack.js:20:30)
at Object.<anonymous> (index.pack.js:534:12)
at __webpack_require__ (index.pack.js:20:30)
at index.pack.js:66:18
at index.pack.js:69:10
Can someone please help me solve this issue?