Mobx

Author: Published Updated

How do you debug unexpected MobX re-renders and infinite update loops?

MobX's trace() helper shows exactly which observable changes triggered a reaction, making it easier to track down unexpected renders or infinite loops. Wrap components with trace() during development to log the dependency chain that caused each update.


Debugging

trace()

trace() helps show what it was that made MobX update. this is helpful for tracking down unexpected renders or infinite loops.

import {trace} from 'mobx-react'
{...}
render() {
trace();
return ();
}

toJS()

Each observable has a method of toJS() on it. May need to look into typing them correctly.


< Helpers React TypeScript >