eslint react hooks rules do not work when a component is wrapped in observer
Author: javiergonzalez-synthCreated Oct 20, 2025Updated Oct 30, 2025
Labels🐛 bug
This is not really a but report in MobX itself (sorry), but I just wanted to point out that react-hooks eslint rules (other than dependency checking) are not working at all for components wrapped in observer (or wrapped in any function other than react built-ins like memo/forwardRef) for that matter.
There's an (ugly) workaround though, which is wrapping a named function:
const Component = observer(function Component() {
...
})that perhaps could be added to the docs.
I created a fix 3 weeks ago - https://github.com/facebook/react/pull/34608 - but it seems it didn't gain much traction , which is a shame because these rules are useful even in the mobx-react world (and even worse, I found they stopped working by pure chance)
Source: mobxjs/mobx