SERG
SERG

Reputation: 3971

Add js lib to react component

I am new to react and I want to connect it with a lib inside the component. For example I want to create a map component and I dpn't want to use any existing wrappers for mapboxGl. I want to use it like this https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.1/mapbox-gl.js'> inside the component. I know that I can connect it in index.html, but is there a way to connect from component. Something like

import map from 'https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.1/mapbox-gl.js';

And what is there is no npm module for this lib?

Thanks.

Upvotes: 1

Views: 52

Answers (1)

staHo
staHo

Reputation: 74

You should be using npm to gather packages to react.

npm install --save mapbox-gl

Then you will be able to import this package to your project

Upvotes: 1

Related Questions