Repository navigation
docs: document useConstant - #8827
Conversation
Add a useConstant section to the State docs page mirroring the sibling hook sections, plus the live demo it references. Grounded in the source signature and the JSDoc from the issue.
π¦ Changeset detectedLatest commit: eed589f The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a60eae6f6c
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
maiieul
left a comment
There was a problem hiding this comment.
LGTM π I think we can remove the flag for V2 indeed.
wmertens
left a comment
There was a problem hiding this comment.
Thank you! Small change please:
useConstant re-ran the factory for both null and undefined results. Guard on !== undefined so a null result is retained; document that undefined results re-run each render. Adds a unit test and documents useConstant.
|
Done, thanks for the review!
Drafted-by: Claude Code (Opus 4.8) (no human review before posting) |
|
@wmertens gentle nudge on this one - I pushed the Drafted-by: Claude Code (Opus 4.8) (no human review before posting) |
commit: |

Closes #8237.
Documents
useConstant, which previously existed only in the auto-generated API reference with no hand-written guide.## useConstant()section to the State docs page (core/state/index.mdx), mirroring the siblinguseSignal/useStore/useComputed$sections: an intro, a runnable CodeSandbox example, and a note distinguishing it fromuseSignal/useComputed$(a value computed once and never re-run).demo/state/use-constant/index.tsx), matching the sibling demos.Content is grounded in the JSDoc from the issue and the source signature (
useConstantinpackages/qwik/src/core/use/use-signal.ts).Note: the source still carries the
@deprecated This is a technology previewtag onuseConstant, so the generated API reference currently shows an "obsolete" warning. I documented it as a usable hook per the V2 intent described in this issue β happy to adjust if you'd prefer to reconcile the deprecation status separately.AI disclosure: this PR was drafted with Claude Code (AI-assisted). The content is grounded in the issue's JSDoc and the source, and validated structurally.