react-toolbox/docs/app/components/layout/main/modules/examples/snackbar_example_1.txt

39 lines
905 B
Plaintext
Raw Normal View History

2015-11-01 17:19:45 +03:00
class SnackbarTest extends React.Component {
2015-11-12 07:25:14 +03:00
handleSnackbarClick = (event, instance) => {
console.log('handleSnackbarClick', event, instance);
this.setState({ active: false });
};
handleSnackbarTimeout = (event, instance) => {
console.log('handleSnackbarClick', event, instance);
this.setState({ active: false });
};
2015-11-01 17:19:45 +03:00
handleClick = () => {
2015-11-12 07:25:14 +03:00
this.setState({ active: true });
2015-11-01 17:19:45 +03:00
};
2015-11-12 07:25:14 +03:00
state = {
active: false
2015-11-01 17:19:45 +03:00
};
render () {
return (
<section>
<Button label='Show snackbar' raised primary onClick={this.handleClick} />
2015-11-01 17:19:45 +03:00
<Snackbar
2015-11-12 07:25:14 +03:00
action='Dismiss'
active={this.state.active}
label='Snackbar action cancel'
2015-11-21 07:24:14 +03:00
timeout={2000}
2015-11-01 17:19:45 +03:00
onClick={this.handleSnackbarClick}
2015-11-12 07:25:14 +03:00
onTimeout={this.handleSnackbarTimeout}
type='cancel'
/>
2015-11-01 17:19:45 +03:00
</section>
);
}
}
return <SnackbarTest />;