Renaming Widget Error: Cannot read property 'widgetType' of undefined

3243
17
Jump to solution
02-15-2021 10:43 AM
DaveFullerton
Occasional Contributor III

Update:  If you read through you will find that renaming widgets was the issue.

Up to now I have been working with Dev Edition v1.1 and wanted to try migrating to v1.3. When I ran into trouble, I tried migrating to v1.2 where I did not encounter this error:

Capture.PNG

My project has 2 custom widgets that I developed, but only one of them fails. A third widget that also fails is simply a copy of the argis-map widget that I renamed and made a few changes in mapbase.tsx to disable all navigation (replacing/enhancing the functionality of the disable zoom scrolling option). All 3 custom widgets worked correctly in v1.3 when I tested them in a new ExB project. Again, I have no problems migrating to v1.2.


I also see errors in the server command window:

Capture2.PNG

Any thoughts regarding this would be appreciated.

0 Kudos
17 Replies
DaveFullerton
Occasional Contributor III

Yes, the widgets are in the dist folder.  This is what it looks like if I copy and paste the URL in a new tab:

image.png

This is what it looks like when I Preview the app:

image.png

0 Kudos
AlexisCuicui
New Contributor II

Could you try to create a new experience from scratch and try to add your own widget inside ?

It may give some leads on what is failing ?

0 Kudos
DaveFullerton
Occasional Contributor III

Thanks, Alexis, as stated in the original post I have tried that:

All 3 custom widgets worked correctly in v1.3 when I tested them in a new ExB project.

0 Kudos
DaveFullerton
Occasional Contributor III

This showed up now too:

image.png

0 Kudos
DaveFullerton
Occasional Contributor III

The NODE_TLS_UNAUTHRIZED error may be a hint that CORS needs to be enable.  Hopefully I will hear back from IT about getting privileges set back to where there were so I can do that.  A new error has cropped up:

image.png

0 Kudos
Junshan_Liu
Occasional Contributor
The widget name is changed. Take op-whmn-search as a sample, it's called op-search in the config.json, but the widget name is changed to op-whmn-search, that's the reason why the widget can't be found.
DaveFullerton
Occasional Contributor III

Thank you, Junshan.  To differentiate the names between the widgets for this Experience from the ones for an Experience that followed, I renamed the widgets.  This was a long while back.  When I tested the projects in v1.1, everything worked fine.  I made changes and redeployed the Experience multiple times - but made no changes to the custom widgets.  It seems to me that the reason the widgets continued to work is that after I renamed the widgets there were functioning orphans in the client\dist\widgets directory.

So I guess the question now becomes:  "Is there a way to rename widgets and fix Experiences that reference them?"

As you say, the config.json file in server\src\public\apps\5 did not have the correct widget names.  I updated them, but it still didn't work.  I then found the config.json file in server\src\public\apps\5\resources\config and updated it.  This did the trick.

So from what I have seen so far, it seems that after renaming a widget, you should:

1. Delete the orphan in client\dist\widgets.

2. Change all references to the name of the widget in server\src\public\apps\[#]\config.json and server\src\public\apps\[#]\config.json.

 

0 Kudos
Junshan_Liu
Occasional Contributor

To change a widget name, you need to:

1. Stop webpack in client

2. Change the folder name

3. Change the name in manifest.json

4. Change the reference in apps/#/config.json and apps/#/resource/config.json (one config is for published version, one config is for draft version)

5. Start webpack