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