I get this error when I try to catch all the routes
TypeError: Cannot read properties of undefined (reading 'length')
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Here's my code:
import {useRouter} from "next/router";
function Docs() {
const route = useRouter();
const {params} = route.query;
console.log(params);
if(params.length === 1){
return (
<div>
<h1>Docs {params[0]}</h1>
</div>
)
}
else if (params.length === 2){
return (
<div>
<h1>Docs {params[0]} feature </h1>
</div>
)
}
else{
return (
<div>
<h1>Docs home page</h1>
</div>
)
}
}
export default Docs
Here's my folder structure: Project Folder structure
and I'm following this Youtube Video for learning NextJS, Somebody help me out. Thanks.