Overview
This module provides custom React hooks for handling common UI patterns like auto-focusing inputs and automatic scrolling.useScrollToBottom
Automatically scrolls an element to the bottom when dependencies change. Useful for chat interfaces, logs, or any scrollable content that should stay at the bottom when new items are added.Parameters
React ref of the container element that should scroll to bottom
Array of dependencies that should trigger the scroll behavior. The scroll occurs whenever any of these values change.
Usage Example
Implementation
source/hooks/use-scroll-to-bottom.ts:8
useFocusOnLoad
Automatically focuses an input element when loading completes. Useful for improving UX by automatically focusing form inputs after data loads.Parameters
Boolean flag indicating whether the component is currently in a loading state. When this becomes
false, the input will be focused.Return Value
A ref object to attach to the textarea element that should receive focus
Usage Example
Implementation
source/hooks/use-focus-on-load.ts:3
Common Patterns
Auto-scrolling Lists
Use
useScrollToBottom for chat interfaces, activity feeds, or log viewers that should automatically show the latest content.Smart Focus Management
Use
useFocusOnLoad to improve form UX by automatically focusing inputs after async operations complete.