Skip to content

Mobx Support #162

Description

@thunderkid

Is this library compatible with Mobx?

I'm trying to adapt the why-did-you-render official example to run with Mobx 5.
As soon as I put a @observer decorator above BigListPureComponent, I stop getting any why-did-you-render console notifications.

@observer
class BigListPureComponent extends React.PureComponent {
  static whyDidYouRender = true;
  render() {
    console.log(
      "BigListPureComponent Re-Render! - We don't want to get here too often."
    );
    return (
      <div style={this.props.style}>
        <h2>BigListPureComponent</h2>
        <div>
          {times(3000).map(n => (
            <div key={n}>Element #{n}</div>
          ))}
        </div>
      </div>
    );
  }
}

However, I still get the regular console.log notification, so it's clearly still being rendered unnecessarily. I've tried multiple permutations such as extending from React.Component, but as soon as I add in @observer it stops working.

Is there an example of this library working with Mobx or are they incompatible? I don't see any mention in the docs one way or the other. Thanks.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestwontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions