Root Component Not Re-rendering #8235
-
Hello! I'm encountering an issue where the Root component in my CodeSandbox example does not re-render when logout is called, even though the cache is cleared using Expected Behavior: I expected Root to re-render when logout clears the cache, causing the user state to reset. However, this doesn’t seem to happen, and Root stays in its current state. Could you please help me understand why Root is not re-rendering in this scenario, or if there’s something I may need to adjust? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This seems more like an architectural problem. Usually, you’d have different routes for “public” areas (login, signup) and “protected” areas (after login). When the user logs out, I usually just call |
Beta Was this translation helpful? Give feedback.
queryClient.clear()
, same asqueryClient.removeQueries
does not inform currently rendered components. If you want that, you wantqueryClient.resetQueries
. However, I’m not sure what that would achieve: You would logout, and then the root would re-render, in which case the login query runs again, which, idk, fails?This seems more like an architectural problem. Usually, you’d have different routes for “public” areas (login, signup) and “protected” areas (after login). When the user logs out, I usually just call
queryClient.clear()
andredirect('/login')
, because thelogin
page doesn't use any queries...