import * as React from 'react'; import { FlashMessage, ReduxState } from '@/redux/types'; import { connect } from 'react-redux'; import MessageBox from '@/components/MessageBox'; type Props = Readonly<{ spacerClass?: string; flashes: FlashMessage[]; }>; class FlashMessageRender extends React.PureComponent { render () { if (this.props.flashes.length === 0) { return null; } return ( { this.props.flashes.map((flash, index) => ( {index > 0 &&
} {flash.message}
)) }
); } } const mapStateToProps = (state: ReduxState) => ({ flashes: state.flashes, }); export default connect(mapStateToProps)(FlashMessageRender);