-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose routing promises #11564
Comments
Very cool! I guess you can do this as well. const [isPending, startTransition] = useTransition()
startTransition(async () => {
const [more, stuff] = await Promise.all([fetcher.submit({ stuff }, { method: "post" }), doSomething()]);
}); |
@ryanflorence so, is that included in react-router@7.1.1? if not, any ETA on this topic? Looking forward to it, thanks :-) |
@wondering639 this is already on v7 |
Parts of this are on v7 - the methods return promises - but at the moment they don't resolve through with the data since that posed some technical issues when we first did the work. We do hope to get that added in the future though. let result = await fetcher.submit();
// result will be undefined, `data` will be in `fetcher.data` |
For me it was not working as expected. However, if you submit again, fetcher.data will return the result from the first submission, as if there is a one-step delay. async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
e.preventDefault();
const formData = new FormData();
formData.append("action", "createUploadUrl");
await fetcher.submit(formData, {
method: "post",
action: "/resources/upload",
});
console.log("data", fetcher.data);
}
|
🤖 Hello there, We just published version Thanks! |
In order for React Router transitions to compose with React 19 transitions we need to expose the promises from all of our transition functions:
This way developers can call into React Router from inside a React transition
Will add in 7.1
The text was updated successfully, but these errors were encountered: