← Back to Articles
Finding Your Voice
All onSections(sections.map(...)) calls in CurriculumStep were using sections captured at render time. If addLesson updated state and the component re-rendered between the API call and the .map(), the closure still held old sections data — so saveLesson would map over a list that didn't include the just-added lesson, effectively discarding it. Every call is now onSections(prev => prev.map(...)), which React guarantees passes the absolute latest state. Click here for more
/

