Open this example in the interactive library
Live preview
Source code
// components/CycleCountVariance.tsx
import { useState } from "react";
export default function CycleCountVariance({ target = 10 }: { target?: number } = {}) {
const [actual, set] = useState(target);
return (
<label>
Actual units
<input type="number" value={actual} onChange={(e) => set(+e.target.value)} />
<output>Variance {actual - target}</output>
</label>
);
}
