Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
shadcn-hooks | 27c2f26 | Commit Preview URL Branch Preview URL |
Feb 27 2026, 07:43 AM |
📝 WalkthroughWalkthroughAdds a new SSR-safe Changes
Sequence DiagramsequenceDiagram
participant Component
participant Hook as useLocalStorageState
participant LocalStorage
participant Sync as useSyncExternalStore
participant OtherTab as OtherTab
Component->>Hook: call(key, initialValue, options)
Hook->>LocalStorage: read key
alt value present
LocalStorage-->>Hook: serialized value
Hook->>Hook: deserialize & cache
else no value or SSR
Hook->>Hook: use initialValue or in-memory fallback
end
Hook->>Sync: subscribe(storage events & local emitter)
Component->>Hook: setValue(new)
Hook->>Hook: serialize (options.serializer)
Hook->>LocalStorage: write key
Hook->>Hook: update cache & emit LOCAL_STORAGE_STATE_EVENT
Sync-->>Hook: notify subscribers
Hook-->>Component: updated state
OtherTab->>LocalStorage: write same key
LocalStorage-->>Hook: storage event
Sync-->>Hook: notify
Hook->>Hook: deserialize & update cache
Hook-->>Component: synced state
Component->>Hook: removeValue()
Hook->>LocalStorage: remove key
Hook->>Hook: reset cache to initialValue & emit event
Hook-->>Component: cleared state
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/registry/hooks/use-hash/demo/demo-01.tsx`:
- Around line 36-40: The Input field using value={inputValue} and
onChange={setInputValue} with placeholder='Type hash without #' lacks an
accessible label; add an explicit label (e.g., a <label> or
aria-label/aria-labelledby) tied to this Input so assistive tech can identify it
— ensure the label references the Input (use htmlFor/id or aria-labelledby) and
use a clear name like "Hash" or "Hash (without #)" while keeping the existing
placeholder and props.
In `@src/registry/hooks/use-local-storage-state/index.mdx`:
- Line 3: Update the description line in the MDX frontmatter for
use-local-storage-state so it reads "An SSR-safe behavior" instead of "A
SSR-safe behavior" — locate the description field in
src/registry/hooks/use-local-storage-state/index.mdx and change the leading
article from "A" to "An".
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
content/docs/introduction.mdxskills/shadcn-hooks/SKILL.mdskills/shadcn-hooks/references/useLocalStorageState.mdsrc/registry/hooks/meta.jsonsrc/registry/hooks/use-hash/demo/demo-01.tsxsrc/registry/hooks/use-hash/index.mdxsrc/registry/hooks/use-local-storage-state/demo/demo-01.tsxsrc/registry/hooks/use-local-storage-state/index.mdxsrc/registry/hooks/use-local-storage-state/index.test.tssrc/registry/hooks/use-local-storage-state/index.tssrc/registry/hooks/use-local-storage-state/registry-item.json
🔥 Files not summarized due to errors (1)
- content/docs/introduction.mdx: Error: Server error: no LLM provider could handle the message
| @@ -0,0 +1,56 @@ | |||
| --- | |||
| title: useLocalStorageState | |||
| description: A hook to persist state in localStorage with SSR-safe behavior | |||
There was a problem hiding this comment.
Fix article in description text.
Line 3 should read “An SSR-safe...” instead of “A SSR-safe...”.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/registry/hooks/use-local-storage-state/index.mdx` at line 3, Update the
description line in the MDX frontmatter for use-local-storage-state so it reads
"An SSR-safe behavior" instead of "A SSR-safe behavior" — locate the description
field in src/registry/hooks/use-local-storage-state/index.mdx and change the
leading article from "A" to "An".
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/registry/hooks/use-hash/demo/demo-01.tsx`:
- Around line 20-24: The setHash function currently prepends a '#' without
normalizing input; update setHash to first trim whitespace and strip any leading
'#' characters from the incoming value (e.g., normalize =
value.trim().replace(/^#+/, '')), then build nextHash using the normalized
string (nextHash = normalized ? `#${normalized}` : '') and call
window.location.assign as before; reference the setHash function to apply this
change.
| const setHash = (value: string) => { | ||
| const nextHash = value ? `#${value}` : '' | ||
| window.location.assign( | ||
| `${window.location.pathname}${window.location.search}${nextHash}`, | ||
| ) |
There was a problem hiding this comment.
Normalize user input before building the hash fragment.
If users type a leading #, Line 21 prepends another one and creates ##... in the URL fragment. Strip leading hashes (and whitespace) first.
Proposed fix
const setHash = (value: string) => {
- const nextHash = value ? `#${value}` : ''
+ const normalized = value.trim().replace(/^#+/, '')
+ const nextHash = normalized ? `#${normalized}` : ''
window.location.assign(
`${window.location.pathname}${window.location.search}${nextHash}`,
)
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const setHash = (value: string) => { | |
| const nextHash = value ? `#${value}` : '' | |
| window.location.assign( | |
| `${window.location.pathname}${window.location.search}${nextHash}`, | |
| ) | |
| const setHash = (value: string) => { | |
| const normalized = value.trim().replace(/^#+/, '') | |
| const nextHash = normalized ? `#${normalized}` : '' | |
| window.location.assign( | |
| `${window.location.pathname}${window.location.search}${nextHash}`, | |
| ) | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/registry/hooks/use-hash/demo/demo-01.tsx` around lines 20 - 24, The
setHash function currently prepends a '#' without normalizing input; update
setHash to first trim whitespace and strip any leading '#' characters from the
incoming value (e.g., normalize = value.trim().replace(/^#+/, '')), then build
nextHash using the normalized string (nextHash = normalized ? `#${normalized}` :
'') and call window.location.assign as before; reference the setHash function to
apply this change.
Summary by CodeRabbit
New Features
Documentation
Tests
Chores