Skip to content

mobx-react-lite@4.0.2 observer not triggering component re-renders #3671

@johnsonsu

Description

@johnsonsu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions