To get access to the page context 1.0
The written instructions say to use the following variable in your web part class.
To get access to the page context Use the following variable in your web part class:
TypeScript
Copy this.context.pageContext
But in the video you paste it and then remove it. There is no function associated with the variable. Leaving it in doesn't cause an error and the rest of the tutorial runs as expected if I leave it in the code. However, later when I try to host the WebPart in the O365 CDN by running gulp serve --ship I get an error and the build does not complete. It did tell me that the error was at line 90 of the .ts file and that variable did not have a function. Which is pretty nice.
I am not that strong a coder so not sure which is correct, the video or the text, but they probably should be clarified for less skilled readers so you don't get all the way to the ship step and have to go back. If this is covered in some other part of the tutorial I obviously missed it.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 71e8ee66-fe7c-a46e-eeec-fb199962042c
- Version Independent ID: f78aef17-5aa2-8807-73d4-509faecbd153
- Content: Connect your client-side web part to SharePoint (Hello World part 2)
- Content Source: docs/spfx/web-parts/get-started/connect-to-sharepoint.md
- Product: sharepoint
- GitHub Login: @spdevdocs
- Microsoft Alias: spdevdocs
So, I think the video is stating "if you want access to contextual information, you can use this.context.pageContext.,,, to access it." But if you have it hanging out in the middle of your code without using the property, I assume that tslint (which is a tool that says "hey, your code can compile, but it's doing some weird stuff that you should take a look at") is causing the ship build to fail.
I've updated the written part of the document to make it clear that you don't write this.context.pageContext on it's own, rather it is simply stating "this is the code you will use later on".
It might take a little while to show up.
Thanks Pat.
From: Pat Miller [mailto:[email protected]] Sent: Tuesday, December 11, 2018 7:43 PM To: SharePoint/sp-dev-docs [email protected] Cc: Blasingame, Bob [email protected]; Author [email protected] Subject: Re: [SharePoint/sp-dev-docs] To get access to the page context 1.0 (#3094)
So, I think the video is stating "if you want access to contextual information, you can use this.context.pageContext.,,, to access it." But if you have it hanging out in the middle of your code without using the property, I assume that tslint (which is a tool that says "hey, your code can compile, but it's doing some weird stuff that you should take a look at") is causing the ship build to fail.
I've updated the written part of the document to make it clear that you don't write this.context.pageContext on it's own, rather it is simply stating "this is the code you will use later on".
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/SharePoint/sp-dev-docs/issues/3094#issuecomment-446418119, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AqOLQtJS3yBH8clt42hgSIKUvqmFw5moks5u4FD_gaJpZM4ZNnTR.
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues