How to import a JS library into a React application?

I am currently using: https://github.com/naikus/svg-gauge

I would like to configure the library for my specific needs, that is, I cannot use the npm package, since I need to configure the library:

import Gauge from 'svg-gauge';

I moved the gauge.js file to: /assets/libs/gauge.js

And then tried to use it like this:

import Gauge from '../../../assets/libs/gauge';

This does not work ... Is it possible to import this JavaScript library into React, allowing me to customize it?

thank

+4
source share
2 answers

It seems that the problem with the undeclared variable kin shallowCopy()adds the declaration to line 96 in shallowCopy()like this:

function shallowCopy(/* source, ...targets*/) {
   var target = arguments[0], sources = slice.call(arguments, 1);
   sources.forEach(function(s) {
     for(var k in s) {
       if(s.hasOwnProperty(k)) {
         target[k] = s[k];
       }
     }
   });
   return target;
 }

, npm, , , , .

+4

, , , , - . Webstorm/IntelliJ, ctrl + , .

0

Source: https://habr.com/ru/post/1692730/


All Articles