Wrap a React component with exact render dependency tracking.
functionleaf<T,U>(fn:(p:T)=>U):(p:T)=>U
let leaf:('a =>'b)=>'a =>'b
leaf wraps a component and uses exact render boundaries to track reads of Tilia proxies during rendering.
When tracked keys change, the wrapped component re-renders. The API is equivalent to a higher-order component and is preferred over useTilia for React integration.
useTilia enables reactive tracking for a component's current render. Call it at the top of the component.
Reads of Tilia proxies during rendering become dependencies. When one of those dependencies changes, the component re-renders. useTilia is the hook form; leaf is the preferred wrapper when possible.
Compute a React value and re-render only when the result changes.
functionuseComputed<T>(fn:()=>T):T
let useComputed:(unit =>'a)=>'a
useComputed evaluates fn with reactive tracking and returns its result.
The hook compares successive computed results and re-renders when the result changes. This differs from plain render reads, which depend on every tracked key read during rendering.
Create a React API bound to a specific Tilia context.
functionmake(tilia: Tilia): TiliaReact
let make: tilia => tilia_react
make from @tilia/react builds a React integration object (useTilia, useComputed, leaf) from a provided core Tilia context.
Use it with core make when an application needs isolated reactive worlds that do not affect one another.
The package-level exports provide the default-context version; this function provides the context-bound version.
Example
import{ make as makeCore }from"tilia";import{ make as makeReact }from"@tilia/react";const ctx =makeCore();const reactApi =makeReact(ctx);void reactApi.useTilia;
let ctx =Tilia.make()let reactApi =TiliaReact.make(ctx)ignore(reactApi.useTilia)
import{ make as makeCore }from"tilia";import{ make as makeReact }from"@tilia/react";importtype{ TiliaReact }from"@tilia/react";const reactApi: TiliaReact =makeReact(makeCore());void reactApi.leaf;