As a beginner in Next.js and React, I'm facing an issue with redirecting users from the "Projects" page to the Product Page Details. Here's the code snippet I am using:
const openProjectDetails = () => {
Router.push('/api/' + props.projetos.key);
}
This is the code found in the "/api/[key].js" file:
import { useRouter } from 'next/router';
const ProjectDetails = () => {
const router = useRouter();
const { key } = router.query;
return (
<div>
{/* Display the project details */}
</div>
);
};
export default ProjectDetails;
I seem to be missing something, as this specific page is giving me an error related to const router = useRouter();
Apologies if this seems basic or if I'm new to this technology.
Error: Cannot read properties of null (reading 'useContext')
I intend to pass the key value to retrieve all project fields from the database, but due to this error, it doesn't work as expected.