Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outdated code example in "File-Based Routing" #836

Open
ayanamists opened this issue Sep 10, 2023 · 0 comments
Open

Outdated code example in "File-Based Routing" #836

ayanamists opened this issue Sep 10, 2023 · 0 comments

Comments

@ayanamists
Copy link

I'm new to blitzjs. I tried the code example in the page File-Based Routing:

import { useParam } from "blitz"

const Post = () => {
  const pid = useParam("pid")

  return <p>Post: {pid}</p>
}

export default Post

blitz dev produce such error:

TypeError: (0 , blitz__WEBPACK_IMPORTED_MODULE_1__.useParam) is not a function
    at Post (webpack-internal:///./src/pages/posts/[pid].tsx:12:64)
    at renderWithHooks (/data/image-data/caoliu/str/caoliu-frontend/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5658:16)
    at renderIndeterminateComponent (/data/image-data/caoliu/str/caoliu-frontend/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5731:15)
    at renderElement (/data/image-data/caoliu/str/caoliu-frontend/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5946:7)

It seems that the useParam function should be imported from @blitzjs/next. I found this solution in #3446. So maybe it's better to update the docs?

@ayanamists ayanamists changed the title Outdated code example in File-Based Routing Outdated code example in "File-Based Routing" Sep 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Triage
Development

No branches or pull requests

2 participants