react-router icon indicating copy to clipboard operation
react-router copied to clipboard

Expose routing promises

Open ryanflorence opened this issue 9 months ago • 1 comments

In order for React Router transitions to compose with React 19 transitions we need to expose the promises from all of our transition functions:

navigate()
submit()
fetcher.submit()
fetcher.load()
revalidator.revalidate()

This way developers can call into React Router from inside a React transition

let [isPending, startTransition] = useTransition()
startTransition(async () => {
  let stuff = await doSomething()
  let more = await fetcher.submit({ stuff }, { method: "post" })
});

Will add in 7.1

ryanflorence avatar May 17 '24 21:05 ryanflorence

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()]);
});

bluefire2121 avatar May 18 '24 00:05 bluefire2121