import React from 'react'; import MessageBox from '@/components/MessageBox'; import { State, useStoreState } from 'easy-peasy'; import { ApplicationStore } from '@/state'; type Props = Readonly<{ byKey?: string; spacerClass?: string; className?: string; }>; export default ({ className, spacerClass, byKey }: Props) => { const flashes = useStoreState((state: State) => state.flashes.items); let filtered = flashes; if (byKey) { filtered = flashes.filter(flash => flash.key === byKey); } if (filtered.length === 0) { return null; } return (
{ filtered.map((flash, index) => ( {index > 0 &&
} {flash.message}
)) }
); };