0

I am building the amazon clone from the clever programmer youtube channel and when I open a second tab, the basket is not shared on that tab, but if I login, the signin change to signOut in both tabs, so it's confusing. for the state management, I am using useContext and useReduce in the two files: reducer.js and stateProvider.js

here is the code: https://github.com/allaoua-rico/amazon-clone

and the live version: https://clone-c6bdf.web.app/

TBA
  • 1,921
  • 4
  • 13
  • 26

1 Answers1

-1

This generally means you need to 'lift state' to a higher component. I haven't looked at your code, but (as an example) two tabs need to share state. Both tabs are part of a tabset. You would store state in the tabset and either pass state and change methods down to each tab or use context. This way, as the user moves from one tab to the next and back again both tabs retain state.

Steve -Cutter- Blades
  • 5,057
  • 2
  • 26
  • 40