#TypeScript definition differences between Remix and React Router

1 messages · Page 1 of 1 (latest)

grim granite
#

Hi.
I tried both Remix and React Router, and I found that there are several differences between them.
For example, Remix’s useLoaderData can take a loader function type, whereas React Router’s one cannot.
It seems React Router has poor support for type checking.

Now I have 2 questions.

  1. Is it planned to update React Router’s type definition for better type checking?
  2. Is it possible to use @remix-run/react in React Router applications for better TypeScript support?
flint gazelle
#

regarding 2, I think most things will probably work but some may need integration with Remix

#

the way type inference works in useLoaderData is by casting the return type to the loader function, so you just do that useLoaderData() as Awaited<ReturnType<typeof loader>>