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

157
Views
Can't set default useState to incoming redux data

I need to set state with the default value from a redux reducer. I can console.log the value just fine, I'm guessing its not "fast" enough?

I tried setting a variable to the reducer value I need then calling useState with the variable but that didnt work either...

const ChatProvider = ({ children }) => {
  
  const conversations = useSelector((state) => state.conversations) // all conversations

  
  const [activeConversationId, setActiveConversationId] = useState(conversations[1]?.conversationSid)
  console.log(conversations[1]?.conversationSid) // I get my string "Ox990"
  console.log(activeConversationId) // I get undefined...

// render stuff here

}
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!