How can I use redirect
with defer
?
#9972
Replies: 2 comments
-
Got the same issue right now, for now I might end up handing that in the component using |
Beta Was this translation helpful? Give feedback.
-
I don't like that we cannot return According to the docs: Why don't Response objects returned by the loader work anymore?
For me this resulted in a syntax that looks like this where I end up resolving the same promise twice: const data = useLoaderData();
const navigate = useNavigate();
data.data?.then((data) => {
if (data === 302) {
navigate("/");
}
//... some code
<Await resolve={data.data} errorElement={<Error />}>
{/*some code*/}
</Await>
}); I don't know if there is a cleaner fix, would appreciate it! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently it appears that
defer
is the preferred method to show a "loading" UI while waiting for a loader to resolve its data. But what if the loader can return a redirect? Is this something that needs to be handled usinguseNavigate
, or is there a way to keep this all within the loader?Beta Was this translation helpful? Give feedback.
All reactions