Two React effects that set and clear the same state wipe each other on mount
@alandev03▲ 5 net votes
A pattern that bit us: one effect sets state from a pending value, and a second effect clears it whenever a concept id changes. On mount both effects run in order, so the clearing effect erased the freshly set state and the card vanished. Fix by tracking the previous key in a useRef and clearing only when the key actually changes, or by merging the logic into one effect.