Skip to content
This repository has been archived by the owner on Jul 8, 2022. It is now read-only.

Any alternatives to using loadModules.then? #87

Closed
ciesin-frank opened this issue Apr 5, 2019 · 5 comments
Closed

Any alternatives to using loadModules.then? #87

ciesin-frank opened this issue Apr 5, 2019 · 5 comments

Comments

@ciesin-frank
Copy link

We're using version 4.0.0 of the @esri/react-arcgis npm package.

I have a question about using this package within a react project.

Is there a way, outside of using the loadModules function, to load modules that we need?

For example, if we try to create a new Circle object outside of the 'loadModules.then' function, we get this error "'Circle' is not defined no-undef".

If we try to import the Circle object from the react-arcgis package:

import { Circle } from '@esri/react-arcgis'

We get this error: "Attempted import error: 'Circle' is not exported from '@esri/react-arcgis'.".

We also tried this:

import { Circle, Graphic } from 'esri-loader';

But then this code:

        const circle = new Circle({
            center: center,
            radius: radius,
            radiusUnit: "meters"
        });

Causes this error:

TypeError: esri_loader__WEBPACK_IMPORTED_MODULE_9__.Circle is not a constructor

We totally understand we may have to use the loadModules function to load the modules we need, but we're wondering if there's another, perhaps simpler way.

Thanks.

@abdel-abdelrazek
Copy link
Contributor

Have a look on that package
https://www.npmjs.com/package/@arcgis/webpack-plugin

@ciesin-frank
Copy link
Author

We're currently using the create-react-app and the @esri/react-arcgis packages. Can this @arcgis/webpack-plugin package be used in addition or is it an alternative package?

@abdel-abdelrazek
Copy link
Contributor

It is alternative package, it will enable you from importing esri staff like the following.
import SceneView from "esri/views/SceneView";

@ciesin-frank
Copy link
Author

Thanks for the info.

@tomwayson
Copy link
Member

@ciesin-frank

You may have trouble using @arcgis/webpack-plugin w/ create-react-app: Esri/arcgis-webpack-plugin#12

If so, you'll need to use esri-loader and/or react-arcgis, which means you will not be able to import esri modules .

If your problem is that loadModules() is async, you might check out the patterns I link to here: Esri/esri-loader#150

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

No branches or pull requests

3 participants