1 import React from 'react'
2 import styles from './Flash.scss'
4 class Flash extends React.Component {
5 componentWillReceiveProps(nextProps) {
6 Object.keys(nextProps.messages).forEach(key => {
7 const item = nextProps.messages[key]
9 this.props.markFlashDisplayed(key)
15 if (!this.props.messages || this.props.hideFlash) {
20 // Flash messages are stored in an objecty key with a random UUID. If
21 // multiple messages are displayed, we rely on the browser maintaining
22 // object inerstion order of keys to display messages in the order they
24 Object.keys(this.props.messages).forEach(key => {
25 const item = this.props.messages[key]
27 <div className={`${styles.alert} ${styles[item.type]} ${styles.main}`} key={key}>
28 <div className={styles.content}>
29 {item.title && <div><strong>{item.title}</strong></div>}
33 <button type='button' className='close' onClick={() => this.props.dismissFlash(key)}>
47 import { connect } from 'react-redux'
49 const mapStateToProps = (state) => ({
50 hideFlash: state.tutorial.isShowing && state.routing.locationBeforeTransitions.pathname.includes(state.tutorial.route)
53 export default connect(