Skip to main content
@juo/blocks/react is the React 18+ adapter. It exposes createReactRenderer and a set of hooks for context and signal interop.
The patterns below extend the Blocks, Reactivity, and Contexts concept pages with React-specific equivalents.

Defining a React block

createReactRenderer mounts the component inside a ContextProvider that resolves context from the surrounding <juo-context-root>. Hooks inside the tree can then call useContext and useSignal.

Reading services with useContext

useContext (the one from @juo/blocks/react, not React’s own) returns a proxy where every Signal<T> becomes a [value, setValue] tuple driven by useSyncExternalStore. Components re-render when accessed fields change:
The $ accessor returns the raw service when direct signal access is required:

useSignal — read any signal as React state

For signals that aren’t part of a context (a service-internal signal, a computed, an externally created one), useSignal bridges to React state:

Providing contexts from React

Use useProvideContext inside a wrapper component: