0

I want to ask how pass a array value to the properties.

Always at first should be 'properties name', but I have got a lot repetable names. So I want give them to the Array. How I can pass them ? If I put them in this sort of code i get a lot of errors in Console. here is my code in properties text:

PropertyPaneTextField(this.properties.linkArray[0], {
            label: "Kafel nr 1"
          }),

I need to pass a lot of values but if I tried put this I getting a lot of errors. Please help me.

  • 1
    this.properties.linkArray[0] should be a string – harshal gite Oct 28 '19 at 9:23
  • 1
    But why arey you storing it in array? Are all property names in your array only? – harshal gite Oct 28 '19 at 9:30
  • 1
    Because 'propertyName' is used in your render methods to get the value from the property pane using this.properties.propertyName . So it is recommended to have a hard coded name to avoid conflicts. – harshal gite Oct 28 '19 at 9:34
  • 1
    Property name should be unique for each property – harshal gite Oct 28 '19 at 9:37
  • 1
    See what I'm trying to say is, react uses the props in it's render method to refer to the changes made to the properties in the property pane. That has to be unique and known to react v-dom an that is the reason it has to be declared in properties. Instead of defining linkArray inside properties, you can declare it as an array outside and create a function to push property dynamically to the "groupFields" – harshal gite Oct 28 '19 at 12:42
0

Grzegorz,

You may want to look at the PropertyFieldCollectionData control from
@pnp/spfx-property-controls.

You can find more information here: https://sharepoint.github.io/sp-dev-fx-property-controls/controls/PropertyFieldCollectionData/

You can also look at the source code if you need to understand how it works.

I hope this helps?

  • I using this controls. So that's why I can't use this. – Grzegorz Z Oct 28 '19 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.