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

70
Views
Store spreaded props output in single array

I'm looking for some help on a function I'm working on which, captures events from socket changes (socket.io), everything works fine but, since I'm making use of spreaded props, I'd like to store the arrays coming through in to a single array.

what I have

      const handlers = (...args) => {
          const result = [args];
          console.log(result);
      }

      socket.onAny(handlers);
      //socket.on('posts', handler);

OUTPUT RESULT

but I'd like to have the expected result:

Array[[{}], [{}], [{}]]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

here is the end result

const [changes, setChanges] = useState([]);


//Check socket changes
    useEffect(() => {
      const result = []

      const handlers = (...args) => {
        result.push(args)
        setReplies(result)
      }

      socket.onAny(handlers);

      return () => socket.offAny(handlers);
       //eslint-disable-next-line react-hooks/exhaustive-deps
    }, []);

enter image description here

about 4 years ago · Juan Pablo Isaza Report
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!