Sp-dev-docs: this.properties not initialized with default values (SPFX Client Webpart)

Created on 4 Apr 2018  路  3Comments  路  Source: SharePoint/sp-dev-docs

Category

  • [x] Question
  • [ ] Typo
  • [ ] Bug
  • [ ] Additional article idea

Hi all,

I'm developing a SPFX Modern Site Client webpart that has a large number of properties (currently around 40 and growing).
Due to that, Ive moved the non-critical properties to a form on the webpart itself when in Edit Mode.

The issue I'm having is that all properties in "this.properties" are null on a new Webpart, essentially not using the defaults.

I'm defining all defaults on Webpart.manifest.json

Any ideia why the object is not initialized with the defaults?

Thanks.

spfx-general tracked question

Most helpful comment

Because I don't see what exactly resolved the issue for @Ralms I will leave my case for further readers. I had the same problem when properties initial values were specified in the manifest file, but none of them were set on the webpart.

In my case the problem was old manifest being served by gulp. Until I've restarted the gulp serve command old manifest was used (that didn't contain new properties).

Suggestion by @mpasarin of using Ctrl+F12 to search for manifest was the key here.

All 3 comments

Hi Ralms, thanks for your feedback.

Could you double-check the contents of the manifest? Press Ctrl+F12 in the page and go to the Manifests tab. Find your web part manifest there. Does it contain all the properties in the right preconfigured entries?

Are the properties that you care about "null" or "undefined" (or not defined at all). It's a small but importance difference in JavaScript.

You mentioned that you moved non-critical properties. Before doing that was "this.properties" correctly set up? Now you don't get any property at all in "this.properties", or it's just missing the ones you moved?

Because I don't see what exactly resolved the issue for @Ralms I will leave my case for further readers. I had the same problem when properties initial values were specified in the manifest file, but none of them were set on the webpart.

In my case the problem was old manifest being served by gulp. Until I've restarted the gulp serve command old manifest was used (that didn't contain new properties).

Suggestion by @mpasarin of using Ctrl+F12 to search for manifest was the key here.

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

Was this page helpful?
0 / 5 - 0 ratings