3

There are answers to many similar questions, but I don't what to do in my case because here the root of this error is all the SVGs that I import in React Components.

The page loads blank showing this in the console-

SCRIPT1028: Expected identifier, string or number -main.chunk.js

The error points to this line in main.chunk.js- https://i.stack.imgur.com/oq8Kz.png

As I found upon searching for the error, this error occurs due to Edge not supporting ES6 Spread operator. And one of the solutions I understood was to transpile that code using babel, but how about the SVG?

This is the code for the first SVG due to which the error occurs-

import {ReactComponent as BgDots} from "../../images/bg-dots.svg";

export function Card(props) {
  return (
    <div key={props.id} className={props.id}>
      
      {/* <----- ERROR LINE ------> */}
      <BgDots className="bg-dots" />
    
    </div>
)}

This is the codesandbox of my project. Please help me fix this error!

Sapinder
  • 193
  • 2
  • 14
  • Are you using webpack or parcel? – Panther Jul 17 '20 at 12:19
  • add this to your babel https://babeljs.io/docs/en/babel-plugin-transform-spread – Panther Jul 17 '20 at 12:20
  • https://stackoverflow.com/questions/51778230/react-project-spread-operator-in-node-module-unexpected-token – Panther Jul 17 '20 at 12:25
  • Does this answer your question? [React project - spread operator in node module unexpected token](https://stackoverflow.com/questions/51778230/react-project-spread-operator-in-node-module-unexpected-token) – Panther Jul 17 '20 at 12:25
  • It didn't work! I still get the same error message! – Sapinder Jul 18 '20 at 03:24
  • Which version of Edge are you using? I didn't see the error you saying in Edge Legacy and Edge Chromium and the page can load well in Edge. It looks the same in Edge and Chrome. The result in Edge: https://i.stack.imgur.com/OEWxq.png. The errors in console aren't what you said and aren't specific to Edge. – Yu Zhou Jul 20 '20 at 08:13
  • @YuZhou I just recently installed latest Windows 10 version and it's the pre-installed legacy version. I had the same issue in the previous version. But if it works on your edge, then I think the issue is specific to my edge browser. – Sapinder Jul 20 '20 at 11:15
  • 1
    Yes, maybe. You could also try it in other computers to see if the code can work. My Edge Legacy version is 44.18362.449.0. If it works in other Edge browsers then you can compare the settings of the browsers to see if there's any different. – Yu Zhou Jul 21 '20 at 02:03

0 Answers0