-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
createPage
route params not getting passed to component
#3015
Comments
That is because when creating pages all their paths must be hard-coded. In your case, you must create a page for each user id, and pass the user id and any other relevant data as context to the "template" component. You then retrieve those values from the context with the pathContext property. There's also this, but I have never used it: https://www.gatsbyjs.org/docs/creating-and-modifying-pages/#creating-client-only-routes |
Closing this issue since it's been clarified that Gatsby intends for client-only routes to be the solution to this kind of use case. |
Alternatively, you can use |
Hello there!
When I pass a route param to a page created with the
createPage
action creator ingatsby-node.js
(such as/user/:id
), the param (in this case,id
) isn't included in the props of the component that gets rendered.To double-check, I made a fresh
gatsby new
project using[email protected]
.Here's the contents of
gatsby-node.js
:With that, when I navigate to something like
/user/22972379663372344
, mytest.js
component is rendered and receives the following props (note thatprops.match.params
should have anid
, but it doesn't):The text was updated successfully, but these errors were encountered: