Timeline for SharePoint Framework: How to detect if running on modern or classic page?
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 15, 2017 at 13:29 | vote | accept | Heinrich Ulbricht | ||
Sep 15, 2017 at 13:28 | comment | added | Heinrich Ulbricht |
I updated to 1.2.0 - now your code works. So it was introduced after GA. One note: this import I wrote above does NOT work: import Environment, { EnvironmentType } from "@microsoft/sp-core-library/lib/Environment" - will give webpack module resolution errors.
|
|
Sep 6, 2017 at 9:05 | comment | added | Gautam Sheth | It could be, I think it was added during the GA. However, i am using the code mentioned above only, but I am running the latest version (1.2), which has app customizer at RC, so in your case, it could be different. | |
Sep 6, 2017 at 8:40 | comment | added | Heinrich Ulbricht |
There is no environment on this.context . I'm running on an old framework version (sp-core-library: 1.0.0). Maybe it was added later? import Environment, { EnvironmentType } from "@microsoft/sp-core-library/lib/Environment"; is fine though (this line was added by VSC Intellisense autocomplete and differs from yours).
|
|
Sep 6, 2017 at 8:35 | comment | added | Gautam Sheth |
hmm, can you try it as this.context.environment.type==EnvironmentType.ClassicSharePoint and check ? Try it in the render method.
|
|
Sep 6, 2017 at 8:33 | comment | added | Heinrich Ulbricht |
Sounds perfect. But doing a quick test in SPO with a client side webpart Environment.type is undefined :-/ Any ideas why this could be?
|
|
Sep 6, 2017 at 8:11 | history | answered | Gautam Sheth | CC BY-SA 3.0 |