You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: concepts/toolkit/get-started/build-a-sharepoint-web-part.md
+25-17Lines changed: 25 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,6 @@ This article covers how to use Microsoft Graph Toolkit components in a [SharePoi
24
24
25
25
Follow the steps to [Set up your SharePoint Framework development environment](/sharepoint/dev/spfx/set-up-your-development-environment).
26
26
27
-
28
27
# [React based web parts](#tab/react)
29
28
30
29
## Create your web part project
@@ -49,7 +48,7 @@ The Microsoft Graph Toolkit providers enable authentication and access to Micros
49
48
First, add the provider to your web part. Locate the `src\webparts\<your-project>\<your-web-part>.ts` file in your project folder, and add the following line to the top of your file, right below the existing `import` statements:
@@ -174,30 +175,31 @@ export default class HelloWorldWebPart extends BaseClientSideWebPart<IHelloWorld
174
175
AddthecomponentstotheReactcomponent. Locateandopenthe`src\webparts\<your-project>\components\<your-component>.tsx`fileandaddtheimportforthecomponentyouwanttouse-inthiscase, the `Person` component - and then update the `render()` method to use the Person component. Now your component should look like this:
175
176
176
177
```tsx
177
-
import * as React from 'react';
178
-
import type { IHelloWorldProps } from './IHelloWorldProps';
179
-
import { Person } from '@microsoft/mgt-react';
178
+
import * as React from "react";
179
+
import type { IHelloWorldProps } from "./IHelloWorldProps";
180
+
import { Person } from "@microsoft/mgt-react";
180
181
181
182
export default class HelloWorld extends React.Component<IHelloWorldProps, {}> {
182
183
public render(): React.ReactElement<IHelloWorldProps> {
@@ -219,7 +221,7 @@ The Microsoft Graph Toolkit providers enable authentication and access to Micros
219
221
First, add the provider to your web part. Locate the `src\webparts\<your-project>\<your-web-part>.ts` file in your project folder, and add the following line to the top of your file, right below the existing `import` statements:
220
222
221
223
```ts
222
-
import { Providers } from '@microsoft/mgt-element';
224
+
import { Providers } from "@microsoft/mgt-element";
223
225
import { SharePointProvider } from "@microsoft/mgt-sharepoint-provider";
224
226
```
225
227
@@ -240,7 +242,7 @@ To ensure that your web part works if there are multiple web part solutions usin
240
242
First, update your imports from `@microsoft/mgt-element`
241
243
242
244
```ts
243
-
import { Providers, customElementHelper } from '@microsoft/mgt-element';
245
+
import { Providers, customElementHelper } from "@microsoft/mgt-element";
244
246
```
245
247
246
248
Next, update the `onInit()` method to set up disambiguation. The string used for disambiguation must be unique to your SharePoint Framework solution:
@@ -259,7 +261,7 @@ protected async onInit() {
259
261
Now, you can start adding components to your web part. First import the relevant register functions:
260
262
261
263
```ts
262
-
import { registerMgtPersonComponent } from '@microsoft/mgt-components';
264
+
import { registerMgtPersonComponent } from "@microsoft/mgt-components";
263
265
```
264
266
265
267
> [!NOTE]
@@ -334,6 +336,8 @@ npm i --save-dev babel-loader@8.3.0 @babel/plugin-transform-optional-chaining @b
334
336
335
337
### Modify the webpack configuration
336
338
339
+
#### Webpack version <=4
340
+
337
341
SharePoint Framework provides an extensibility model to [modify the webpack configuration](/sharepoint/dev/spfx/toolchain/extending-webpack-in-build-pipeline) used to bundle the web parts. Locate and open `gulpfile.js`. Add the following code above the line containing `build.initialize(require('gulp'));`
This ensures that the code from the `lit` library is correctly processed by the SharePoint Framework build chain.
373
+
This ensures that the code from the `lit` library is correctly processed by the SharePoint Framework build chain. This is required for Sharepoint provider `<=v1.18`.
374
+
375
+
#### Webpack version 5+
376
+
377
+
There is no additional configuration when you're using version 5+ of webpack. This is supported with the Sharepoint provider `v1.19+`.
0 commit comments