Created
November 16, 2017 05:25
-
-
Save exiva/2e3398888ef23d4d3a75bede240e013d to your computer and use it in GitHub Desktop.
This file contains 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
function WarningBanner(props) { | |
if (!props.warn) { | |
return null; | |
} | |
return ( | |
<Section> | |
<Text>Hai.</Text> | |
</Section> | |
); | |
} | |
class SettingsPage extends SettingsComponent { | |
constructor(props) { | |
super(props); | |
this.state = {showWarning: true} | |
this.handleToggleClick = this.handleToggleClick.bind(this); | |
} | |
handleToggleClick() { | |
this.setState(prevState => ({ | |
showWarning: !prevState.showWarning | |
})); | |
} | |
render() { | |
return ( | |
<Page> | |
<WarningBanner warn={this.state.showWarning} /> | |
<Section> | |
<Button | |
label="Toggle" | |
onClick={ this.handleToggleClick } | |
/> | |
</Section> | |
</Page> | |
); | |
} | |
} | |
function mySettings(props) { | |
return ( | |
<SettingsPage /> | |
); | |
} | |
registerSettingsPage(mySettings); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment