UNPKG

redux-security

Version:
45 lines (34 loc) 1.12 kB
import React, { PropTypes} from 'react' import { warning, write } from 'redux-journal' import Snackbar from 'material-ui/Snackbar' import { types } from '../actions' import { SERVICE, TAGS } from '../config' import { select } from '../select' const tags = `${TAGS}.react.snackbar.logout` class AuthSnackbarLogout extends React.Component { constructor(props, context) { super(props, context) const { serviceName = SERVICE } = props this.state = { serviceName, value: false } } componentWillReceiveProps = (nextProps) => { const auth = select(nextProps.auth) if (auth.status() == types.LOGOUT_REQUEST) this.setState({ value: true }) } onRequestClose = () => this.setState({ value: false }) render() { return ( <Snackbar open={ this.state.value } message='LOGOUT' autoHideDuration={ 2000 } onRequestClose={ this.onRequestClose } /> ) } } AuthSnackbarLogout.propTypes = { auth: PropTypes.object.isRequired, serviceName: PropTypes.string } export default AuthSnackbarLogout