Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

bug: ES6 syntax "static variable async vs static variable = async" #678

Closed
meabed opened this issue May 29, 2019 · 5 comments · Fixed by #682
Closed

bug: ES6 syntax "static variable async vs static variable = async" #678

meabed opened this issue May 29, 2019 · 5 comments · Fixed by #682
Labels

Comments

@meabed
Copy link
Contributor

meabed commented May 29, 2019

Thanks for the update and maintaining the project.

In the last v6.0.0
Applying @Inject, static properties are not copied correctly if its defined in this syntax


@inject('store')
@observer
class Btn extends Component {
  // ❌ not working
  static async getInitialProps () {
    console.log("static");
  };
  render() {}
}

When you change it to variable based it works


@inject('store')
@observer
class Btn extends Component {
  // ✅this works
  static getInitialProps = async () => {
    console.log("static");
  };
  render() {}
}

My guess is the issue is in copyStaticProperties

Could you guys have a look at this as it breaks any components now.
I am using it in nextjs as reference here.

Thank you and keep up the awesome work 👍

@urugator
Copy link
Contributor

https://github.com/mobxjs/mobx-react/blob/master/src/utils/utils.js#L69
Object.keys(base) has to be replaced by Object.getOwnPropertyNames(base) to include non-enumerables.
The check base.hasOwnProperty(key) is redundant, both .keys/.getOwnPropertyNames returns own props.

@meabed
Copy link
Contributor Author

meabed commented May 29, 2019

Yes, absolutely need to change, thanks for the suggestion 👍
image

@mweststrate
Copy link
Member

PR welcome!

@meabed
Copy link
Contributor Author

meabed commented May 31, 2019

@mweststrate PR ready :) Thanks! #682

@lock
Copy link

lock bot commented Jan 14, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or questions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants