Dynamic page omit assertion of router.query

Hey , I am using an eslint rule that prevents me from invalid template literals. Is there anything I can do to omit pid as string ?
import { useRouter } from 'next/router'

const Post = () => {
const router = useRouter()
const { pid } = router.query

return <Link href={`/somepath/${pid}`}>Click</Link> // @typescript-eslint/restrict-template-expressions pid - string | string[] | undefined
}

export default Post
import { useRouter } from 'next/router'

const Post = () => {
const router = useRouter()
const { pid } = router.query

return <Link href={`/somepath/${pid}`}>Click</Link> // @typescript-eslint/restrict-template-expressions pid - string | string[] | undefined
}

export default Post
1 Reply
WOLG
WOLGOP2y ago
Assertion makes this link href='somepath/undefined' in page source Should I just return null when the page is rendered on a server Or whats the solution
Want results from more Discord servers?
Add your server