Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

101
Views
How can I build a notification stack using Alert + Collapse?

I'm building a web app with Material UI. I'm trying to make a notification stack using Alert. (I know notistack, but I don't like it.)

I think about the following...

  1. I have to have a stack of notifications.
  2. The app stacks the notifications.
  3. When the user clicks a button, it shows all the notifications that are in the stack.

To implement this I think I should use Alert + Collapse. One big problem I see is that every Collapse needs a hook (created with useState). I'm not quite sure how to do this. Also, using the AllNotify array (see the code that follows) as the notification stack is not working.

Can someone help me?

let AllNotify = [];

export const NotifyPush = (severity,msg) => {
    AllNotify.push({severity: severity, msg: msg});
};

const NotifyBalloon = (notify) => {
    //const [open, setOpen] = useState(true);

    return (
        <Collapse in={true}>
            <Alert sx={{boxShadow: 2}}
                   icon={<CheckIcon fontSize="inherit" />} severity={notify.severity}
                   action={
                       <IconButton
                           aria-label="close"
                           color="inherit"
                           size="small"
                           onClick={() => {}}
                       >
                           <CloseIcon fontSize="inherit" />
                       </IconButton>
                   }>
                {notify.msg}
            </Alert>
        </Collapse>
    );
};


export const NotifyStack = (props) => {
    return (
        <Stack sx={{ width: '95%' }} spacing={1}>
            {
                AllNotify.reverse().map((notify) => NotifyBalloon(notify))
            }
        </Stack>
    );
};
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!