0

Failed to compile.

Error in ./src/View.js Syntax error: C:/workspace/reactsapp/my-shop/src/View.js: Unexpected token (77:69)

  75 |     const [mainImage, setMainImage] = useState(product);
  76 |     const [orderQuantity, setQuantity] = useState(setOrderQuantity());
> 77 |     const [orderedProduct, setOrderProduct] = useState(getStorage() ?? [])
     |                                                                      ^
  78 |     const [headerKey, setHeaderKey] = useState(Math.random())
  79 |     useEffect(async () => {
  80 |         // setQuantity(3)

@ ./src/index.js 17:12-29

Why getting this error after working with such syntax for a long now.

you can see the previous working commit at https://github.com/codad5/wemall-frontend/commit/709dd9bf1ed598ffdeef706e9191509d870acdc7

the GitHub link https://github.com/codad5/wemall-frontend/

although I haven't committed this current code with this bug

I am running on node version v17.4.0

Codad5
  • 1
  • 2
  • How are you compiling the app? How is the compiler/bundler configured? – Felix Kling Apr 13 '22 at 21:18
  • nullish operator `??` was introduced in node 14, are you sure the current node version you have installed is 14 or above ? – Florent Bouisset Apr 13 '22 at 20:42
  • It is a react app so i simply write `npm start` to start/run the project – Codad5 Apr 13 '22 at 23:05
  • @FlorentBouisset node version doesn't matter as this code is runner in the browser. What matters is babel configuration. OP changed the react-scripts version and that's what is causing the problem probably – Konrad Apr 14 '22 at 23:30

0 Answers0