Code Room
Vibe codingMedium
Question
An AI wrote this React Native screen that subscribes to a native BLE event emitter and updates a heart-rate display. It runs, but the number updates wildly out of order, sometimes flickers backward, and on Android occasionally throws about updating an unmounted component. What's wrong and how would you fix it?
function HeartRate() { const [bpm, setBpm] = useState(0); useEffect(() => { const emitter = new NativeEventEmitter(BleModule); emitter.addListener('hr', (e) => { setTimeout(() => setBpm(e.value), 0); // "defer to be safe" }); }, []); return <Text>{bpm} bpm</Text>;}What a strong answer looks like
Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.