2021年1月2日星期六

Nextjs router query parameters not logging

I am trying to log the query parameter in a Nextjs project. I never see the value logged, but the value shows up on the page. Should I just ignore that the logs in npm dev dont show the query parameter or should I handle the case where it's undefined?

/test/[test].js

import {useRouter} from "next/router";  import React from "react";    const Test = () => {      const router = useRouter();      const {test} = router.query;      console.log(router.query); // {}      console.log(test);  // undefined      return <div>          <h1>{test}</h1>      </div>  };  export default Test;  

enter image description here

https://stackoverflow.com/questions/65546008/nextjs-router-query-parameters-not-logging January 03, 2021 at 10:07AM

没有评论:

发表评论