blitz-js / blitz-js/blitzjs.com
Outdated code example in "File-Based Routing"
- Dominant language
- MDX
- Stars
- 188
- Forks
- 316
- PR merge metrics
- No merged PRs in 30d
Description
I'm new to blitzjs. I tried the code example in the page [File-Based Routing](https://www.blitzjs.cn/docs/routing):
```js
import { useParam } from "blitz"
const Post = () => {
const pid = useParam("pid")
return
Post: {pid}
}
export default Post
```
`blitz dev` produce such error:
```shell
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](https://github.com/blitz-js/blitz/issues/3446). So maybe it's better to update the docs?
Contributor guide
No contributing guide indexed for this repository
Research direction
Open the File-Based Routing page at https://www.blitzjs.cn/docs/routing and inspect the useParam example. Compare its import with the solution referenced in issue #3446, then update the example so it matches the current API. Done means the documented example uses the valid import and no longer produces the reported useParam error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100