mobx: `mobx-react-lite@4.0.2` observer not triggering component re-renders

The observer of mobx-react-lite seems to not trigger the wrapped component to re-renders after upgrading from mobx-react-lite@3.4.3 to mobx-react-lite@4.0.2.

Intended outcome:

When an observable value changes in the store, the observer component should re-render with the new value.

Actual outcome:

The observer component does not re-render when the observable value is updated.

How to reproduce the issue:

Code Sandbox: https://codesandbox.io/s/new-dawn-b2shxq?file=/src/App.js

Clicking “Push new element to data” button will push a new element to the store.data array using a store action.

However, the component does not re-render even thought store.data has been updated (see console logs).

If you change the mobx-react-lite version from 4.0.2 to 3.4.3 in the sandbox, the component will re-render when you click the “Push new element to data” button.

Screenshot 2023-03-27 at 7 49 23 PM

Versions

mobx-react-lite@4.0.2

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 6
  • Comments: 17 (5 by maintainers)

Most upvoted comments

Reverted latest tag back to mobx-react@7.6.0 / mobx-react-lite@3.4.3, and deprecated the newer majors.

We reverted the 4.x release, we’ll release it again, but needs some more time. For now stick to 3.x

On Wed, 26 Apr 2023, 09:33 YoungSeon.Ahn, @.***> wrote:

Has this issue been resolved? I’m waiting so long.

— Reply to this email directly, view it on GitHub https://github.com/mobxjs/mobx/issues/3671#issuecomment-1522925931, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN4NBEX2FUD6RWMYHFVOUTXDDFUXANCNFSM6AAAAAAWJZWIM4 . You are receiving this because you were mentioned.Message ID: @.***>

mobx-react v8.0.0 broke my apps. I wrap my app in StrictMode in development. If I remove StrictMode, it all works again. I already pushed another app to production but StrictMode is disabled in production so I dodged a bullet there.