Skip to content

api-console with react #680

Description

@FranciscoGileno

Hi!

Congrats for this lib. It is great!

I am trying to make it run with a new instance of create-react-app. I already installed the package npm -i --save api-console, and my code is:

import "api-console";

import "./App.css";

function App() {
  return (
    <div className="App">
      <header className="App-header">
        <api-console
          style={{ height: "400px" }}
          modelLocation="/api-model.json"
        />
      </header>
    </div>
  );
}

export default App;

I've got: Uncaught SyntaxError: Identifier 'module' has already been declared

It seems create-react-app and api-console both declared module?

Can anyone help me?
Thanks.

Activity

  1. jarrodek commented on Mar 18, 2021

    @jarrodek
    Contributor

    Hi,

    Thank you for the issue report. I am not expert in react but I believe you should have reference the component registration file which is api-console/api-console.js so the final import would be:

    import 'api-console/api-console.js';

    There's no module in this project that would cause this error. If this won't help I'll ask @twoplustwoone to help you as he has more experience with React

  2. FranciscoGileno commented on Mar 18, 2021

    @FranciscoGileno
    Author

    Thanks for answering @jarrodek .

    It didn't work. Same error.

  3. jarrodek commented on Mar 19, 2021

    @jarrodek
    Contributor

    I see the problem. The icons library has an icon that is called module. It exports a variable with that name. After webpack compilation there is a function argument called module and then const declaration with the same name. This causes SyntaxError. I though webpack is smarter than that.
    I can actually change the name of the icon as it is not yet widely used but it will take time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions