Skip to content

Commit 047d22a

Browse files
lee-borlaceVesaJuvonen
authored andcommitted
Staging (#313)
* Update this.context.environment.type to Environment.type to avoid issue from drop 6. * Update this.context.environment.type to Environment.type to avoid issue from drop 6
1 parent 96a3e09 commit 047d22a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

docs/spfx/web-parts/get-started/connect-to-sharepoint.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,18 @@ To use the module, you first need to import **EnvironmentType** module from the
242242
import { EnvironmentType } from '@microsoft/sp-client-base';
243243
```
244244

245+
You also need to import **Environment** from the **@microsoft/sp-client-base** bundle to be able to check **EnvironmentType**. Add it to the **import** section at the top as shown in the following code:
246+
247+
```ts
248+
import { Environment } from '@microsoft/sp-client-base';
249+
```
250+
245251
Add the following private method inside the **HelloWorldWebPart** class to call the respective methods to retrieve list data:
246252

247253
```ts
248254
private _renderListAsync(): void {
249255
// Local environment
250-
if (this.context.environment.type === EnvironmentType.Local) {
256+
if (Environment.type === EnvironmentType.Local) {
251257
this._getMockListData().then((response) => {
252258
this._renderList(response.value);
253259
}); }
@@ -262,7 +268,7 @@ private _renderListAsync(): void {
262268

263269
Things to note about hostType in the **_renderListAsync** method:
264270

265-
* The `this.context.environment.type` property will help you check if you are in a local or SharePoint environment.
271+
* The `Environment.type` property will help you check if you are in a local or SharePoint environment.
266272
* The correct method is called depending on where your workbench is hosted.
267273

268274
Save the file.

0 commit comments

Comments
 (0)