-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
defineRoute: runtime #11736
defineRoute: runtime #11736
Conversation
|
let routePath = path.resolve(ctx.reactRouterConfig.appDirectory, routeFile); | ||
let code = await (readRouteFile?.() ?? fse.readFile(routePath, "utf-8")); | ||
|
||
// temporary back compat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: should probably create a "remove back compat" and add links to that in these comments so its easier to track these down later.
<ComponentNeedingProps | ||
// @ts-expect-error | ||
params={params} | ||
data={data} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data={data} | |
loaderData={data} |
let Component = ComponentNeedingProps | ||
? () => { | ||
let params = useParams(); | ||
let data = useLoaderData(); | ||
let actionData = useActionData(); | ||
return ( | ||
<ComponentNeedingProps | ||
// @ts-expect-error | ||
params={params} | ||
data={data} | ||
actionData={actionData} | ||
/> | ||
); | ||
} | ||
: undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right now HMR tests are failing. pretty sure that this part is to blame since were dynamically creating a new component every time we want to render the route's component.
for a quick implementation, I think it'd be easiest to just create a virtual mod for each route (similar to what we already do for production) that re-exports from the route module's default export and wraps the Component
.
a more principled solution would be to find out how we pass in data from loaders and actions and stop relying on hooks altogether. that would probably remove the need to wrap the Component
from a route.
The approach of wrapping a component in the React Router runtime (e.g. in |
No description provided.