I am trying to show multiple message using provider and hooks . But I am not able to show multiple message .One one message is show at one time don’t know why ?
here is my code
https://codesandbox.io/s/new-mountain-cnkye5?file=/src/App.tsx:274-562
React.useEffect(() => {
setTimeout(() => {
utilContext.addMessage("error 2 sec");
}, 300);
setTimeout(() => {
utilContext.addMessage("error 5 mili sec");
}, 2000);
setTimeout(() => {
utilContext.addMessage("error 1 sec");
}, 1000);
}, []);
I am also using map function to render all message.
return (
<>
{messages.map((msg, index) => (
<div key={`Toast-Message-${index}`}>
{msg.msg}
<button
onClick={(event) => {
alert("000");
}}
>
close
</button>
</div>
))}
<ConfirmationDialogContext.Provider value={value}>
{children}
</ConfirmationDialogContext.Provider>
</>
);
Expected output : It will show 3 messages after some time.