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

81
Views
UseState array update

I get a crash when the state tries to push the first element.

export interface ISortedMessages {
sortedMessages: {
    error: Array<Message['message']>,
    warning: Array<Message['message']>,
    info: Array<Message['message']>,
}}

I want to sort the incoming messages as they enter into the useState

switch (message.priority) {
case 0:
    setStateMessages(previousMessages => ({ ...previousMessages, error: [...previousMessages.sortedMessages.error, message.message] }));
    break;}

Thank you in advance! If you believe there's a better way of resolving this, please let me know.

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!