Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use with last version of React.js #203

Open
geoffroyp opened this issue Mar 28, 2022 · 1 comment
Open

How to use with last version of React.js #203

geoffroyp opened this issue Mar 28, 2022 · 1 comment

Comments

@geoffroyp
Copy link

geoffroyp commented Mar 28, 2022

Hi guys,

I'm trying since way too long to import this library in a React project using React's last version. At the moment, it's just a sandbox to try various things.

But I miserably fail everytime. I have tried to:

  • Import it in the public/index.html like any other "old school" scripts: "TS2304: Cannot find name 'EventSourcePolyfill'."
  • Import it in the public/index.html like any other "old school" scripts AND declare it as for angular by using declare var EventSourcePolyfill: any; : Uncaught SyntaxError: Unexpected token '<' (the < symbol is actually the beginning of the <!Doctype> tag of the public/index.html page
  • Import it like a module: import * as ES from "../node_modules/event-source-polyfill/src/eventsource.min.js"; -> nope: Could not find a declaration file for module '../node_modules/event-source-polyfill/src/eventsource.min.js'
  • Import it like a module: import EventSourcePolyfill from "../node_modules/event-source-polyfill/src/eventsource.min.js"; -> nope, same error
  • Import it like a module: import EventSourcePolyfill from "../node_modules/event-source-polyfill/src/eventsource.min.js"; -> nope, Could not find a declaration file for module 'event-source-polyfill'.

etc, etc...

I'm new to react, so i'm probably doing something wrong, but I hardly understand why we couldn't import it like any other module with a simple import EventSourcePolyfill from "event-source-polyfill";

Any idea / savior?

@sbx0
Copy link

sbx0 commented Apr 1, 2022

You can import like this import {EventSourcePolyfill} from "event-source-polyfill";
Full Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants