Pass Array Values from webpart.ts to Main.tsx
-
08-02-2021 - |
سؤال
I am fetching data from webpart.ts using this.properties.data and present it as list items in Main.tsx. However, It only displays as a string like Select Google rather than
- select
What am I missing?
webpart.ts
IMylinkWebPartProps
> {
private temp = new Set();
private handleClick() {
this.temp.add(this.properties.linkName);
let array = [];
this.temp.forEach(v => array.push(v + "\n"));
this.properties.data = [...array];
debugger;
}
//codes continue
main.tsx
public render(): React.ReactElement<IMylinkProps> {
console.log(this.state);
let test = [this.props.data];
console.log("test=", test);
return (
//codes continue....
)
المحلول
let test = [this.props.data];
Change to
let test = this.props.data;
sorry, I do not need to create another array while assigning to the test.
لا تنتمي إلى sharepoint.stackexchange