[Bug ?] jimu-arcgis dependency => TypeError this.mapView is undefined

1701
10
02-07-2022 05:34 AM
D_P
by
New Contributor II

Hi all,

adding the jimu-arcgis dependency in the manifest.json causes the following error in custom widgets. I've tried this with my own code and esri's js-api-widget in Exp.B. 1.6 & 1.7. Is anyone else getting the error?

Uncaught (in promise) TypeError: this.mapView is undefined
    updateMapView https://localhost:3001/widgets/arcgis/arcgis-map/dist/runtime/widget.js:1
    componentDidUpdate https://localhost:3001/widgets/arcgis/arcgis-map/dist/runtime/widget.js:1
    promise callback*componentDidUpdate https://localhost:3001/widgets/arcgis/arcgis-map/dist/runtime/widget.js:1
    React 14
    u https://localhost:3001/jimu-core/index.js:2
    createResizeHandler https://localhost:3001/jimu-core/index.js:2
    createResizeHandler https://localhost:3001/jimu-core/index.js:2
    t https://localhost:3001/jimu-core/index.js:2
    React 15
    startRenderMap https://localhost:3001/widgets/arcgis/arcgis-map/dist/runtime/widget.js:446
    setTimeout handler*execute/Ie/this.startRenderMap https://localhost:3001/widgets/arcgis/arcgis-map/dist/runtime/widget.js:446
    componentDidMount https://localhost:3001/widgets/arcgis/arcgis-map/dist/runtime/widget.js:603
    React 8
widget.js:1:26069

 

0 Kudos
10 Replies
DaveFullerton
Occasional Contributor III

@D_P , yes!  Or a least something similar (see below).  Definitely only in 1.6 and 1.7.  I had been wanting to post something about this, but hadn't had the time.  I can confirm that the error also shows up when deployed to the production server.  

I was on a wild goose chase for a while trying to figure this out.  The last thing I thought to try was removing things from manifest.js!  I haven't noticed that it causes any significant problems.  It was just very confusing.

To isolate and test the issue, I added the jimu-arcgis dependency to the manifest of the Simple sample widget.  I added the Simple widget and a Map widget to a project.  The error shows up on page load, and did not show up until I selected a map in the Map widget (tested with Daily COVID-19 Trends from Living Atlas).

@GavinRehkemper , have you experienced this?  Would you mind seeing if you can reproduce it or asking if the development team is aware?  Not sure if it is relevant but I am running node v12.18.3.

 

widget.js:1 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'popup')
at y.updateMapView (widget.js:1:26148)
at widget.js:1:43992
updateMapView @ widget.js:1
(anonymous) @ widget.js:1
Promise.then (async)
componentDidUpdate @ widget.js:1
hu @ react-dom.js:2
zi @ react-dom.js:2
n.unstable_runWithPriority @ react-dom.js:2
Hl @ react-dom.js:2
Ti @ react-dom.js:2
gi @ react-dom.js:2
(anonymous) @ react-dom.js:2
n.unstable_runWithPriority @ react-dom.js:2
Hl @ react-dom.js:2
Kl @ react-dom.js:2
ql @ react-dom.js:2
fi @ react-dom.js:2
enqueueSetState @ react-dom.js:2
h.setState @ react.js:2
(anonymous) @ index.js:2
(anonymous) @ index.js:2
r.createResizeHandler @ index.js:2

 

GavinRehkemper
Esri Contributor

Thank you both for this information. I am able to replicate this issue by following these steps:

  1. Download, unzip and install developer edition of Experience Builder v1.7.
  2. Add code to client\your-extensions\widgets\simple\manifest.json:

 

"dependency": ["jimu-arcgis"],​

 

  • In the browser, create a new Experience.
  • Add the "Simple" and "Map" widgets
  • Save the experience
  • Open the preview
  • Open the browser developer tools (console)
  • Expected: no errors
  • Actual: Error: 

 

 

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'popup')
    at y.updateMapView (:3001/widgets/arcgis/arcgis-map/dist/runtime/widget.js:1:26148)

 

 

 

I'll check into this. Is this error blocking any functionality? Or is this just an error that shows up but is not causing any functional issues?

DaveFullerton
Occasional Contributor III

It caused me no noticeable problems other than confusion, Gavin.  However, I have not put anything from v1.6 or v1.7 into production.  I did migrate my development environment to v1.6 and did limit testing.  No problems there.  I only got started on v1.7 and got pulled away.

0 Kudos
D_P
by
New Contributor II

Thank you, Dave and Gavin! So far it's not causing any functional issues, but it took quite some head scratching to figure out what was going on.

Best regards, Daniel

0 Kudos
GavinRehkemper
Esri Contributor

This issue will be fixed in the next release of developer edition of Experience Builder (v1.8).

0 Kudos
D_P
by
New Contributor II

I've uploaded a little demo.

https://demo.egnaro.net/?data_id=dataSource_1-boreholes_geojson_6489%3A5%2B1%2B3%2B4

In Firefox the error only occurs after the service worker cached the page. So with clean cache (ctrl+F5) there is no error.

DaveFullerton
Occasional Contributor III

Very interesting about the service worker cache.  That further explains why it was so confusing.  Some things I tried with a new project seemed to resolve the issue and then the error was back again when I tried to confirm.

0 Kudos
D_P
by
New Contributor II

There are some mighty strange things going on with the jimu-arcgis dependency and service workers. Once I forgot to add the dependency in a custom widget although I imported GraphicsLayer from esri/layers/GraphicsLayers and some other stuff. Everything worked fine locally but once I got it online the widget said "Fail to load" and I was getting some "window.require is not a function" errors. There was a strange randomness to the issue. Cleaning the cache mostly worked for Firefox but Chrome wasn't working most of the time. I was going absolutely bananas till I figured out all was caused by the missing dependency.

0 Kudos
GavinRehkemper
Esri Contributor

Hi D_P, by default, Experience Builder does not load the ArcGIS API for JavaScript when the app loads. There are two options to use the JS API modules, documented here: https://developers.arcgis.com/experience-builder/guide/extend-base-widget/#modules-in-the-arcgis-api... If you do not do either of those, but try to import a JS API module in your custom code, it will not work and you will likely experience errors like you mention above. I do not think that's related to your original issue, because you are getting the error when the jimu-arcgis dependency is properly included in the manifest.json file.

0 Kudos