Welcome to My Route with Props!
Loader Data: {JSON.stringify(loaderData)}
Action Data: {JSON.stringify(actionData)}
Route Parameters: {JSON.stringify(params)}
Matched Routes: {JSON.stringify(matches)}
);
}
```
--------------------------------
### React Component with Route Props
Source: https://reactrouter.com/start/framework/testing
A sample React component `Login` that accepts `actionData` as a prop, typically provided by React Router's framework mode. This component renders a form with the POST method.
```tsx
export default function Login({
actionData,
}: Route.ComponentProps) {
return Loading...
;
}
export default function Product() {
/* ... */
}
```
--------------------------------
### Define Server Routes for React Router
Source: https://reactrouter.com/start/data/custom
Defines route configurations for server-side rendering using React Router. These are the same route objects used on the client but are utilized by server-side APIs for rendering and data fetching.
```javascript
export default [
{
path: "/",
Component: Root,
children: [
{
path: "shows/:showId",
Component: Show,
loader: ({ params }) => {
return db.loadShow(params.id);
},
},
],
},
];
```
--------------------------------
### Pending Form Submission with Fetcher
Source: https://reactrouter.com/start/framework/pending-ui
This code illustrates how to show a 'Submitting...' state for a form submission using `useFetcher`. This is recommended for independent form mutations as it manages its own pending state separately from global navigation.
```javascript
import { useFetcher } from "react-router";
function NewProjectForm() {
const fetcher = useFetcher();
return (