Skip to content

Instantly share code, notes, and snippets.

@exiva
Created November 16, 2017 05:25
Show Gist options
  • Save exiva/2e3398888ef23d4d3a75bede240e013d to your computer and use it in GitHub Desktop.
Save exiva/2e3398888ef23d4d3a75bede240e013d to your computer and use it in GitHub Desktop.
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