I am still struggling to understand how to use React Router. The documentation is very sparse, to say the least. Types are not defined, leaving me guessing how to do anything. Let's say I have a component.tsx
import type { Route } from "./+types/component";
export async function loader({ params }: Route.LoaderArgs) {
const response = "foo";
return response;
}
export default function Component({ loaderData }: Route.ComponentProps) {
return <div>{loaderData} bar</div>;
}
then I can call the component from the browser with localhost:5173/component no problem.
But what if I want to include that component in another page, such as call-component.tsx
import type { Route } from "./+types/call-component";
import Component from "./component";
export default function CallComponent() {
return <Component />;
}
Now I get this error:
Type '{}' is missing the following properties from type 'ComponentProps': params, loaderData, matchests(2739)
🌟 Highlight Code
(alias) function Component({ loaderData }: Route.ComponentProps): JSX.Element
import Component