How to navigate outside of the React tree?
#819
Replies: 3 comments 7 replies
Until this is answered, do you know the last version where it is still included? |
1 reply
|
Use router.navigate or simply use the history.pushState/replaceState api.
Tanner Linsley
…On Apr 21, 2024 at 12:43 PM -0600, KarticJoshi ***@***.***>, wrote:
Did you find any solution to this?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
4 replies
Answer selected by
tokarchyn
|
What would be a recommended option if I'd like to redirect the user on a network request failure? export const baseQueryWithAuthCheck = (
path: string,
{ headers, userId, ...options }: ApiRequestOptions = {},
) => {
...
return fetch(`${API_HOST}${path}`, {
...options,
credentials: "include",
headers: requestHeaders,
}).then((response) => {
if (response.status === 401 || response.status === 403) {
void router.navigate({ to: "/login", replace: true });
}
return response;
});
};Unfortunately, importing the |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
It seems
Routerdoes not containnavigatefunction anymore as state in docs: https://tanstack.com/router/v1/docs/guide/navigation#routernavigateAll reactions