AI & Agents
Agent
advanced-use-latest
Access latest values in callbacks without adding them to dependency arrays. Prevents effect re-runs while avoiding stale closures.
Claude Code
$ npx -y skills add calcom/cal.diy --agent claude-code
Cursor
Cursor also loads subagents from .claude/agents, so copy this file there to use it in Cursor.
Agent definition
advanced-use-latest.mdtitle: useLatest for Stable Callback Refs impact: LOW impactDescription: prevents effect re-runs tags: advanced, hooks, useLatest, refs, optimization
useLatest for Stable Callback Refs
Access latest values in callbacks without adding them to dependency arrays. Prevents effect re-runs while avoiding stale closures.
**Implementation:**
function useLatest<T>(value: T) {
const ref = useRef(value)
useEffect(() => {
ref.current = value
}, [value])
return ref
}**Incorrect (effect re-runs on every callback change):**
function SearchInput({ onSearch }: { onSearch: (q: string) => void }) {
const [query, setQuery] = useState('')
useEffect(() => {
const timeout = setTimeout(() => onSearch(query), 300)
return () => clearTimeout(timeout)
}, [query, onSearch])
}**Correct (stable effect, fresh callback):**
function SearchInput({ onSearch }: { onSearch: (q: string) => void }) {
const [query, setQuery] = useState('')
const onSearchRef = useLatest(onSearch)
useEffect(() => {
const timeout = setTimeout(() => onSearchRef.current(query), 300)
return () => clearTimeout(timeout)
}, [query])
} Stats
50,225
Stars
Active
Maintenance
TypeScript
Language
MIT
License
Last commit
Created
50k3 skills95 agents
More agents from other plugins.
CSharpExpert.agent
AgentAn agent designed to assist with software development tasks for .NET projects.
coder
AgentFocused coder - implements exactly the assigned subtask in its worktree
Argon
AgentGoogle cross-vendor agent named for the model it runs — Gemini 4 Argon, Google’s top reasoning model, via…
Questions about advanced-use-latest.
- Which coding agents can use advanced-use-latest?
- advanced-use-latest installs in Claude Code and Cursor: each loads subagents from .claude/agents, so copy the file there. Flowy's auto-invocation runs in Claude Code only.

