When I click on a link in my /index.js
, it brings me to /about.js
page.
However, when I\'m passing parameter name through URL (like
url
prop is deprecated as of Next.js version 6:
https://github.com/zeit/next.js/blob/master/errors/url-deprecated.md
To get the query parameters, use getInitialProps
:
import Link from 'next/link'
const About = ({query}) => (
Click here to read more
)
About.getInitialProps = ({query}) => {
return {query}
}
export default About;
class About extends React.Component {
static getInitialProps({query}) {
return {query}
}
render() {
console.log(this.props.query) // The query is available in the props object
return Click here to read more
}
}
The query object will be like: url.com?a=1&b=2&c=3
becomes: {a:1, b:2, c:3}