Skip to content

fix: clear fieldState errors when resolver uses dot-notation string keys#4630

Open
tomeelog wants to merge 1 commit intomobxjs:mainfrom
tomeelog:docs/observer-eslint-hooks-compat
Open

fix: clear fieldState errors when resolver uses dot-notation string keys#4630
tomeelog wants to merge 1 commit intomobxjs:mainfrom
tomeelog:docs/observer-eslint-hooks-compat

Conversation

@tomeelog
Copy link
Copy Markdown

@tomeelog tomeelog commented Apr 2, 2026

Adds a documentation tip to the React integration guide explaining that eslint-plugin-react-hooks rules (e.g. rules-of-hooks, exhaustive-deps) do not work correctly when observer() wraps an arrow function expression, because the linter cannot identify it as a React component.

The tip shows the workaround: pass a named function to observer() instead.

Addresses #4594

Code change checklist

  • Added/updated unit tests
  • Updated /docs. For new functionality, at least API.md should be updated
  • Verified that there is no significant performance drop (yarn mobx test:performance)

…with observer

When a component is wrapped with `observer` using an arrow function
(the most common pattern in examples), `eslint-plugin-react-hooks` rules
such as `rules-of-hooks` and `exhaustive-deps` silently stop working
because the plugin does not recognise the wrapped result as a React
component.

Add a new collapsible tip section that:
- explains why the problem occurs
- shows that using a named function inside `observer` fixes it
- cross-references the displayName tip since both share the same solution
- mentions the `componentWrapperFunctions` eslint-plugin-react option
  as a partial workaround (and clarifies its limitations)

Related: mobxjs#4594
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 2, 2026

⚠️ No Changeset found

Latest commit: 803edfc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant