useRef
import { useRef, Text } from "@pibbl/core";useRef(init?) is render-only and returns one stable PibblRef with a generic mutable
current field for the component identity. Updating current does not schedule
a render. Its normal hook slot lifetime ends when the component unmounts; do
not use it to preserve state across a changed component identity.
function Counter() { const renders = useRef(0); renders.current = (renders.current ?? 0) + 1; return <Text>{renders.current}</Text>;}Use useSignal for values that should schedule updates.
API details from source
Section titled “API details from source”
Hook: Creates a reference object, similar to React’s useRef.
useRef: <T>(init?: T) => PibblRef<T>Related API: useRef, PibblRef.
Parameters
Section titled “Parameters”init— The initial reference value
Returns
Section titled “Returns”A reference with a current property containing the value
See also
Section titled “See also”View source — packages/core/src/lib/hooks/use-ref.ts:20
Implementation guidance for agents
Section titled “Implementation guidance for agents”Read the Authoring, signals, and lifecycle companion for ownership, adaptation, failure modes, and verification. Agent start provides the version-selection workflow.
Complete minimal examples
Section titled “Complete minimal examples”- Component-owned state and reactions: Click to update a signal, derive a value, and publish an imperative effect after commit. Plain source
Documentation version
Section titled “Documentation version”Documentation built with @pibbl/core 0.0.2, revision 272a94a. ALPHA — NOT FOR PRODUCTION USE.