Created
February 28, 2020 17:01
-
-
Save cwparsons/e29374c3594970a43628b13e9a450dbe to your computer and use it in GitHub Desktop.
Detect if an SharePoint Framework (SPFx) web part is in display mode or not, using TypeScript.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { DisplayMode } from '@microsoft/sp-core-library'; | |
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base'; | |
import * as React from 'react'; | |
import * as ReactDom from 'react-dom'; | |
export default class SampleWebPart extends BaseClientSideWebPart<{}> { | |
public render() { | |
ReactDom.render( | |
<div> | |
{this.displayMode === DisplayMode.Edit ? <span>Edit mode</span> : null} | |
{this.displayMode === DisplayMode.Read ? <span>Read mode</span> : null} | |
</div>, | |
this.domElement | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment