In my previous project, we had been plagued by a UI bug for quite some time. Every time it popped up in production, we escalated the issue a bit. Then it was indeed mitigated by some patch fixing. But the issue was always lurking and could still come back and bite us anytime. Finally, we decided to dedicate a whole sprint to get to the bottom of the issue.
The app has some tabs which share some parent components. When switching the tabs, it updates some states in parent components. The issue is when switching too fast, the states in tabs are somehow messed up and thus data is corrupted. After a sprint's thorough looking, it boils down to this piece of code:
useEffect(() => {
getPreferences(sourceType).then(preferences => setPreferences(preferences));
}, [...]);
Pretty simple code, but the big issue with this is when the tabs are switched too fast, by the time the Promise resolves, the sourceType
is updated and the preferences
is not valid anymore. Once this is figured out, the