score:0

Accepted answer
setHierarchy((prevState) =>
    prevState ? [...prevState, ...selectedSubEvent] : selectedSubEvent
    );

score:1

setHierarchy((prevState) => prevState? [...prevState, selectedSubEvent] : [selectedSubEvent])

setHierarchy((prevState) => [...prevState as Event[], selectedSubEvent])

Related Query

More Query from same tag