Skip to content

Step 11

Gunjan Datta edited this page Jun 16, 2021 · 11 revisions

Set Page Context

SPFx solution will require the page context to be set. Since we will reference the classic solution, we will need to set the page context in the library.

src/index

Copy Assets

spfx/src/webparts/listWebPart/ListWebPartWebPart.ts

Reference the Library

We will reference the classic solution's library.

// Reference the solution
import "../../../../dist/demoListWP.min.js";
declare var WPList;

Render Method

  • Load Data - Load the list data.
    • Set Page Context - In order for the $REST library to execute successfully, the page context will need to be set.
  • Render the Table - After loading the data, render the table.
public render(): void {
    // Load the data
    WPList.load(this.context.pageContext).then(items => {
      // Render the table
      WPList.renderTable(this.domElement, items);
    });
}