简体   繁体   中英

Uncaught SyntaxError Cannot use import statement outside a module

I am getting this error with react-iframe. How should i resolve it?

Version: react@16.13.1 react-iframe@1.8.0 (Please let me know if I have to add any more details)

  import Iframe from 'react-iframe
  import React, { Component } from "react";

  class TableList extends Component {
  render{
  return(
  <div>
    <Iframe url="some url"
    width="100%"
    height="1000"
    id="myId"
    // className="embed-responsive-item"
    display="initial"
    position="relative"
    X-Frame-Options="deny"
    />

  </div>
)
}
}
export default TableList;

`

So not sure if it was a copy/paste mistake but all imports must be defined between two quotes:

  import Iframe from 'react-iframe'
  import Iframe from 'react-iframe';
  import React, { Component } from "react";

  class TableList extends React.Component {
    render() {
    return(
      <div>
        <Iframe url="some URL"
          width="100%"
          height="1000"
          id="myId"
          // className="embed-responsive-item"
          display="initial"
          position="relative"
          X-Frame-Options="deny"
        />
     </div>
   )
  }
}
export default TableList;

Try this. You forget single quote in iframe import and brackets at render method. render is a method so, it should have ()brackets my friend.

Hope It will help you. Happy Coding!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM