How to use dynamic routes using component class #13360
Unanswered
danielpaz6
asked this question in
Help
Replies: 1 comment 2 replies
-
Did you try something like this? Only wrote it from memory, might be wrong (hope it's proper js) import { withRouter } from "next/router"
class MyComp extends React.Component {
componentDidMount() {
const { id } = this.props.router.query
}
}
export default withRouter(MyComp) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is there an example of Next.JS dynamic routes using component class?
I've read this part in next js docs:
https://nextjs.org/learn/basics/dynamic-routes
And I found this "principles":
But why would I want to give statically bind? I'll need to check in my server-side if the id is valid no? in which function should I check it?
At first, I thought of
didComponentMount
but I'm not sure anymore.Beta Was this translation helpful? Give feedback.
All reactions