React
@ghostry/finity-reactjs builds finity on React's own hooks. Everything finity returns from initialize is a hook, and follows the rules of hooks: call it unconditionally, at the top level of a component or another hook.
import { initialize } from "@ghostry/finity-reactjs";
export const finity = initialize({});State
useStrictlyTransitionalState and useTransitionalState keep the state in a React useState, so a transition rerenders the component like any state update.
state.value() returns the state as of the current render, like any React state. A transition is checked against the latest state, though, not the render's: a transition from an older render is stale once any render's transition has changed the state.
A state object keeps its identity until the state changes. It's safe in a dependency array, and an equal transition changes nothing a dependency would see.
Effects
Prefer a component per state, rendered from useRender, with React's own useEffect inside it. Depend on the state, which keeps its identity until it changes, so the effect runs once per state and is cleaned up when the state ends. See Effects.
finity's useEffect runs the matching case inside React's useEffect, with the state as its only dependency, so it runs after the render in which the state changed, once per change. A case's return value is ignored, so it can't clean up.
React's Strict Mode runs effects twice in development. The second run's transition is stale if the first already changed the state, and is reported to onInvalidTransition.
Rendering
useRender(...).use() returns the matching case's ReactNode, so return it from the component, or place it in JSX. A switch with a declared React.JSX.Element return type works too. See Rendering.
