Update WordGameWebPart.ts

This commit is contained in:
Hugo Bernier 2020-05-28 22:37:47 -04:00 committed by GitHub
parent fdddea1979
commit f87f57e0a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 18 deletions

View File

@ -8,28 +8,24 @@ import {
PropertyPaneCheckbox PropertyPaneCheckbox
} from '@microsoft/sp-webpart-base'; } from '@microsoft/sp-webpart-base';
import * as strings from 'WordGameWebPartStrings';
import WordGame from './components/WordGame'; import WordGame from './components/WordGame';
import { IWordGameProps } from './components/IWordGameProps'; import { IWordGameProps } from './components/IWordGameProps';
import { WordService } from './components/WordService';
export interface IWordGameWebPartProps { export interface IWordGameWebPartProps {
gameTitle: string; gameTitle: string;
enableHighScores: boolean enableHighScores: boolean;
} }
export default class WordGameWebPart extends BaseClientSideWebPart<IWordGameWebPartProps> { export default class WordGameWebPart extends BaseClientSideWebPart<IWordGameWebPartProps> {
wordGame: WordGame; public render(): void {
constructor() { if (!this.properties.gameTitle) {
super(); this.properties.gameTitle = 'Word Game';
} }
public render(): void { if (this.properties.enableHighScores === undefined) {
if (!this.properties.gameTitle) this.properties.enableHighScores = true;
this.properties.gameTitle='Word Game'; }
if (this.properties.enableHighScores==null)
this.properties.enableHighScores=true;
const element: React.ReactElement<IWordGameProps> = React.createElement( const element: React.ReactElement<IWordGameProps> = React.createElement(
WordGame, WordGame,
@ -40,9 +36,7 @@ export default class WordGameWebPart extends BaseClientSideWebPart<IWordGameWebP
} }
); );
ReactDom.render(element, this.domElement); ReactDom.render(element, this.domElement);
} }
protected onDispose(): void { protected onDispose(): void {
@ -53,7 +47,7 @@ export default class WordGameWebPart extends BaseClientSideWebPart<IWordGameWebP
return Version.parse('1.0'); return Version.parse('1.0');
} }
//only refresh render after applying settings pane // only refresh render after applying settings pane
protected get disableReactivePropertyChanges(): boolean { protected get disableReactivePropertyChanges(): boolean {
return true; return true;
} }
@ -74,7 +68,7 @@ export default class WordGameWebPart extends BaseClientSideWebPart<IWordGameWebP
}), }),
PropertyPaneTextField('gameTitle', { PropertyPaneTextField('gameTitle', {
label: 'Game Title' label: 'Game Title'
}), })
] ]
} }
] ]