Forum Discussion

PeterKiers's avatar
PeterKiers
Copper Contributor
Apr 13, 2025

How to pass a value from the PropertyPane to the webpart in SPFx?

I have made a SharePoint webpart with the PnP ListPicker on the PropertyPane of the webpart and the PnP DateTimePicker on the webpart itself.

How can I pass the value "Lists:string|string[]" on the PropertyPane:

export interface IPnPDatePickerWpWebPartProps {
  lists: string | string[]; // Stores the list ID(s)
}

To the OnChangeEvent that resides on the webpart itself:

 private handleChanged = async (date: Date): Promise<void> => {
    await sp.web.lists.getByTitle("xxxxxxxx").items.getById(103).update(
      {
        'CustomDate': date
      }
    )
  };

Gr. P

1 Reply

  • michalkornet's avatar
    michalkornet
    Steel Contributor

    Hi PeterKiers , you need to locate the file where the web part properties are defined. This should be in the YOUR_NAMEWebPart.ts file.

    In the interface, you’ll find a default property like description: string.

    export interface IYOUR_NAMEWebPartProps {
      description: string,
      lists: string | string[]; // Stores the list ID(s)
    }

    Then you can access the value by using this.properties.lists