-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
docs(start/framework/route-module): add props example to Component
section
#12838
Conversation
|
Hi @Sanjai451, Welcome, and thank you for contributing to React Router! Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once. You may review the CLA and sign it by adding your name to contributors.yml. Once the CLA is signed, the If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at [email protected]. Thanks! - The Remix team |
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
Thanks @Sanjai451 for helping identify places where the docs could be better. A few notes:
I think we can just update the code example to be something like this: export default function MyRouteComponent({ loaderData, actionData, params, matches }) {
return (
<div>
<h1>Look ma!</h1>
<p>
I'm still using React Router after like 10 years.
</p>
</div>
);
} This doc is meant to be a pretty simple reference, and more details about the different hooks available can be found in the api reference. We plan to add more docs around using these hooks, but this is not the place we want to document them |
docs/start/framework/data-loading.md
Outdated
@@ -135,6 +135,7 @@ export async function clientLoader({ | |||
params, | |||
}: Route.ClientLoaderArgs) { | |||
const res = await fetch(`/api/products/${params.pid}`); | |||
const serverData = await serverLoader({ params }); |
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.
I don't think serverLoader takes any args
docs/start/framework/route-module.md
Outdated
``` | ||
|
||
### Benefits of using props | ||
1. Route data is directly accessible via props, leading to more readable code. |
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.
Another benefit is Route data can be automatically typed if you follow the instructions and import the Route from the +types
Co-authored-by: davidbielik <[email protected]>
Co-authored-by: davidbielik <[email protected]>
Thanks! |
Component
section
This PR improves the docs by adding clear instructions on how to retrieve props in React Router v7. It also covers how to use useLocation, useNavigate, and useParams hooks within route components for better data management and navigation.
Closes #12831