unstated-next icon indicating copy to clipboard operation
unstated-next copied to clipboard

[Question] Understand how to solve the circular dependency issue with Contexts

Open varghesethomase opened this issue 5 years ago • 1 comments

I have two Contexts.

  1. User context
  2. Authentication context I have both of them dependent on each other. Eg: signout is in auth. But create user is dependent on authentication as it has to set user as authenticated after getting the user. And authentication context would have to set user on the user context after login. But the application throws an error as the order in which the application is wrapped can be either be in one way like
<AuthContainer.Provider>
      <UserContainer.Provider>

or

<UserContainer.Provider>
  AuthContainer.Provider>

And this would throw an error like this image

I would like to know if there is any way to solve this.

varghesethomase avatar Nov 25 '19 08:11 varghesethomase

move auth logic into UserContainer

export-mike avatar Dec 06 '19 00:12 export-mike