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

165
Views
ConversationProvider.jsx:25 Uncaught TypeError: Cannot read properties of undefined (reading 'map') at ConversationProvider.jsx:25

Here is the code:

//Create conversation function.
function createConversation(recipients) {
  setConversations(prevConversations => {
    return [...prevConversations, {recipients, messages: []}];
  });
}
//Formatted conversations.
const formattedConversations = conversations.map(conversation => {
  const recipients = conversation.recipients.map(recipient => {
    const contact = contacts.find(contact => {
      return contact.id === recipient;
    });
    const name = (contact && contact.name) || recipient;
    return {id: recipient, name};
  });
  return {...conversation, recipients};
});
//Formatted conversations [END]
//value variable.
const value = {
  conversations: formattedConversations,
  createConversation,
};
//returning ConversationContext.Provider context.
return (
  <ConversationContext.Provider value={value}>
    {children}
  </ConversationContext.Provider>
);

Here I can't map my conversations in the UI

Here is the code which I used in UI:

export default function Conversations() {
  const {conversations} = useConversation;
  return (
    <ListGroup variant="flush">
      {conversations.map((conversation, index) => (
        <ListGroup.Item key={index}>
          {(conversation || []).map(r => r.name).join(', ')}
        </ListGroup.Item>
      ))}
    </ListGroup>
  );
}
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!