Lib Mode: When use the Component prop (config option), pass Route.ComponentProps to the component #13162
Replies: 4 comments 1 reply
-
As noted by @rossipedia, let's also do this for |
Beta Was this translation helpful? Give feedback.
-
Is this even possible? The framework mode relies on a very specific project structure sprinkled with codegen magic, which is incompatible with library mode being shoved into whatever codebase. |
Beta Was this translation helpful? Give feedback.
-
I was interested in getting this to work for an experiment I'm working on (attempting to make a project that works in both framework mode and library mode), and I got a very very hacky version of this to work. This is nowhere near good enough to PR yet, but it Works On My Machine™️: In order to make this work, I had to remove the optimization that pre-renders the |
Beta Was this translation helpful? Give feedback.
-
I think this is pretty reasonable, especially given that our new RSC support for data mode allows for this API In terms of type safety, I don't think we should try to provide any sort of codegen like framework mode has. Framework mode is a our current solution for true type safety for React Router apps I could see us doing something like: function AppLayout({ loaderData, actionData}: ComponentProps<typeof loader, typeof action>) {
/*. */
} Basically nothing more than what we already have for with I'm sure others on the team can weigh in more, but tl;dr:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When you're using React Router in library mode, you can configure the router with routes that have an element or a component. I think it would make a lot of sense for the component to receive the same component props that you get when using React Router in framework mode to better align these two ways of using React Router.
For example:
As for types, I'm not sure whether there's a good way to make that work, but I expect there is. I just think it would be nice to align these ways of building React Router apps.
Beta Was this translation helpful? Give feedback.
All reactions