Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
Import a selfcalling function from an npm module into a react/webpack app

I've build a react app transpiled with webpack and now want to use a package pulled from npm (namely vanilla-cookieconsent). Alas, it's written pretty old school, there is no export or nothing, instead it's just a self calling function that adds a method to the window object. And for the life of me I can't seem to get it into my react/webpack combo.

So, what is the correct way to load and use such a function in a transpiled react app?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Doesn't simply something like

import '~vanilla-cookieconsent/cookieconsent.css';

...

useEffect(() => {
  import('~vanilla-cookieconsent/cookieconsent.js').then(() => {
    // Loading the script should have injected this to window
    window.cookieconsent.run(...);
  });
}, []);

do the trick?

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!