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

260
Views
Recoil library - recoil's value disappears after routers change

I have following recoil atom:

export const BasketA = atom({
    key: 'basket',
    default: [] as any
})

Components on route /test which updates this:

    const [basket, setBasket] = useRecoilState(BasketA);

    const handleAddBookToBasket = () => {
        setBasket((basket: any) => [...basket, book]);
    }

Now if we go to the basket route /basket and do:

    const basket = useRecoilValue(BasketA)

When i console.log this basket, the basket is empty. I know that adding items to basket works, cuz in the first component, console logs displayed correct with filled data

So, my question is: Why the basket is empty after redirect to another route

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!