I'm in the process of creating a WebPart that has similar functionality as the QuickLinks WebPart.
like QuickLinks, I have got the properties pane to display fields depending on whether the webpart edit is clicked or the add or edit link button is clicked.
Next I want to send the link ID to the Property Pane (if edit), which will display the properties from an array/object or, if no id generate new id / link.
then I want to return a updated link or add a new link.
I have tried calling a function defined in the properties pane, it calls the function but the value is undefined. using:-
in the webpart .tsx
this.props.editLinkItem("test-id"); // called when edit button clicked
in the props
export interface IJLinksProps {
editLinkItem:Function;
}
in the property pane .ts
public render(): void {
const element: React.ReactElement<IJLinksProps> = React.createElement(
jLinks,
{
propPaneHandle: this.context.propertyPane,
linkItems: this.properties.linkItems,
editLinkItem: (id:string)=>{
console.log(id)
}
}
);
ReactDom.render(element, this.domElement);
}
any ideas why its undefined?
Another option is setting the id in a State, then how would I get that in the properties?
or has anyone any other ideas. Thanks