小编Sha*_*san的帖子

How to use "useRouter()" from next.js in a class component?

I was trying to get the queries from my url pattern like localhost:3000/post?loc=100 by using useRouter() from "next/router" and fetching some data using that id from my server. It worked when I used it in a Stateless Functional Component.

But the page showing "Invalid hook call" then. I tried calling getInitalProps() of a Stateless Functional Component, but it didn't work there either and showed the same error. Is there any rule to use this method?

I was developing a front-end …

javascript routing reactjs next.js react-hooks

22
推荐指数
2
解决办法
2万
查看次数

标签 统计

javascript ×1

next.js ×1

react-hooks ×1

reactjs ×1

routing ×1