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.

16
  • 1
    this.properties.linkArray[0] should be a string Commented Oct 28, 2019 at 9:23
  • 1
    But why arey you storing it in array? Are all property names in your array only? Commented Oct 28, 2019 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. Commented Oct 28, 2019 at 9:34
  • 1
    Property name should be unique for each property Commented Oct 28, 2019 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" Commented Oct 28, 2019 at 12:42

1 Answer 1

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?

1
  • I using this controls. So that's why I can't use this. Commented Oct 28, 2019 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.