Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobx Support #162

Closed
thunderkid opened this issue Dec 1, 2020 · 3 comments
Closed

Mobx Support #162

thunderkid opened this issue Dec 1, 2020 · 3 comments
Labels
enhancement New feature or request wontfix This will not be worked on

Comments

@thunderkid
Copy link

thunderkid commented Dec 1, 2020

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.

@vzaidman
Copy link
Collaborator

vzaidman commented Dec 5, 2020

Can you add a link to a sandbox of this sort please?
@thunderkid

@vzaidman vzaidman added the enhancement New feature or request label Dec 26, 2020
@vzaidman
Copy link
Collaborator

How do you see mobx support?

For now, we don't support it because of the amount of magic it uses.

I added initial tests and start sandbox here for those who want to play with it:
#169

@vzaidman vzaidman changed the title No logs appearing with Mobx Mobx Support Dec 26, 2020
@vzaidman vzaidman added the wontfix This will not be worked on label Feb 5, 2021
@vzaidman
Copy link
Collaborator

vzaidman commented Feb 5, 2021

I looked at mobx again - I don't believe the library will support it because of how mobx causes re-renders.
We can't really know why-did-you-render if you swallow the logic and cause a re-render on your own terms.
I mean, it's not a criticism, mobx is an amazing library. It's just not compatible with WDYR

@vzaidman vzaidman closed this as completed Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants