Path: blob/1.0-develop/resources/scripts/components/FlashMessageRender.tsx
7461 views
import React from 'react';1import MessageBox from '@/components/MessageBox';2import { useStoreState } from 'easy-peasy';3import tw from 'twin.macro';45type Props = Readonly<{6byKey?: string;7className?: string;8}>;910const FlashMessageRender = ({ byKey, className }: Props) => {11const flashes = useStoreState((state) =>12state.flashes.items.filter((flash) => (byKey ? flash.key === byKey : true))13);1415return flashes.length ? (16<div className={className}>17{flashes.map((flash, index) => (18<React.Fragment key={flash.id || flash.type + flash.message}>19{index > 0 && <div css={tw`mt-2`}></div>}20<MessageBox type={flash.type} title={flash.title}>21{flash.message}22</MessageBox>23</React.Fragment>24))}25</div>26) : null;27};2829export default FlashMessageRender;303132