Question

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
  • Google

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....
)

The problem

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top