Search code examples
reactjsreact-nativeuse-reduceruse-contextreact-usememo

React Native Context Content is keep Coming Back


I want to clear user and do logout in React Native using useContext, useReducer, and useMemo.

My App (AuthContext) has Users Screen (UserContext) in it.

UserContext has clearUsers() within useMemo

AuthContext has logout() within useMemo

UserContext's content is cleared if I do:

clearUsers();

But when I add logout after or before clearUsers, the userContext content is keep coming back after relogin.

clearUsers();
logout();

Anyone experienced this? Please advice.


Solution

  • Turned out that circular import reference casued this. After put context as top reference fixed this issue.