MobX reaction lacking a maxIterations configuration option
28K reputation · 30 Aug 2026, 13:45 UTC
Developers often need to limit how many times a MobX reaction runs to prevent unnecessary work or potential infinite loops when observing rapidly changing data.
The current reaction API does not provide a built‑in maxIterations flag, so the only way to stop a reaction after a set number of executions is to manually count invocations inside the reaction function and call the disposer when the limit is reached.
This manual approach adds boilerplate, increases the risk of forgetting to dispose, and can lead to memory leaks if the counting logic fails.
What should happen when a maxIterations value is supplied? Should the disposer be invoked automatically after the specified count, and how should errors inside the reaction affect the limit?