import { MachineRunner } from '@actyx/machine-runner' import { useEffect, useState } from 'react' import { AuctionP, AuctionT, FirstBidT, InitialP, InitialT, RideP, RideT } from './machines.js' import { PrintState } from './UIMachineCommon.js' import { UIAuctionP, UIInitialP, UIRideP } from './UIMachinePassenger.js' import { UIAuctionT, UIFirstBidT, UIInitialT, UIRideT } from './UIMachineTaxi.js' export const UIMachine = ({ machine, name }: { name: string; machine: MachineRunner }) => { const [state, setState] = useState(machine.get()) useEffect(() => { let active = true ;(async () => { for await (const state of machine) { if (!active) { break } setState(state) } })() return () => { active = false } }, [machine.id]) return (