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

151
Views
Redux toolkit state not getting updated data when call in pusher

I am using redux toolkit to update my real time messages but in pusher bind function the redux state is not getting the updated data.

const messages = useSelector((state) => state.messages.chatMessages);
const chatId = useSelector((state) => state.messages.chatId);

Here is where i am getting data from my redux state and i want to update data in pusher bind function

channel.bind("recChatData", async function (mydata) {

        console.log("chatId", chatId);
        console.log("messagesData", messages);

        if (chatId == mydata.chatId) {
          messagesData = JSON.parse(JSON.stringify(messages));
          messagesData.push(mydata.chatData);
          dispatch(updateMessages(JSON.parse(JSON.stringify(messagesData))));
        }

in the above code the console messagesData is not getting the updated data.Its getting the data from initial load. How can i get my updated data. Please suggest something. Thanks

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!