Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

React Typescript: Ant Design Alert not rendering

I have an Array messages and try to render different Alert if the Status is true but it dont render in the Browser.
Console.log(message) has shown that the message is not empty.

return (
   <Space direction="vertical" >
      {messages.map(item => {
         item.status ?
            <Alert
               message={item.title}
               description={item.statusMessage}
               type="success"
               showIcon
            /> :
            <Alert
               message={item.title}
               description={item.statusMessage}
               type="error"
               showIcon
            />
      })}
   </Space>
);

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Please bear in mind that this map() function will not return anything, because its content is in curly brackets {} and not parentheses (). You could also use return item.status ? ....

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading