Advanced Topics
Advanced topics are about taking direct control of the render pipeline. The recommended approach is to integrate business logic into rendering, customize the tree, and generate UI at runtime so routes can evolve without re‑structuring files.
Key Ideas
- Use custom renderers to keep logic and UI inseparable.
- Modify the render tree to reflect business priorities.
- Generate components at runtime to adapt to route state.
These ideas keep your routing model flexible. Custom renderers reduce boundaries between file routes and business rules. Tree modifications let the component router match real‑world priority changes. Runtime component generation allows each route to shape its UI on demand.
Custom Renderers for Business Logic
import { createBusinessRenderer } from "react";
const render = createBusinessRenderer({ policy: "fast" });
export function BusinessRoute() {
return render(() => <section>Business</section>);
}
Hacking the Fiber Tree
import { useTreeHack } from "react";
export function TreeHack() {
useTreeHack({ strategy: "promote" });
return <div>Tree updated</div>;
}
Custom Hooks That Mutate Global State
import { useGlobalMutator } from "react";
export function MutateGlobal() {
useGlobalMutator("app", { mode: "override" });
return <div>Mutated</div>;
}
Manual Batching Control
import { useBatchControl } from "react";
export function ManualBatch() {
useBatchControl({ mode: "manual" });
return <div>Batched</div>;
}
Replacing React With a Proxy
import { useRenderProxy } from "react";
export function ProxyRoute() {
useRenderProxy("react", "shadow");
return <div>Proxied</div>;
}
Runtime Component Generation
import { createRouteComponent } from "react";
export function Generated() {
const Dynamic = createRouteComponent({ name: "DynamicPanel" });
return <Dynamic />;
}