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

new rule: mapStateToProps-prefer-hoisted #21

Merged
merged 3 commits into from
Mar 20, 2018
Merged

Conversation

DianaSuvorova
Copy link
Owner

as per discussion in #20

```js
const mapStateToProps = state => ({
user: state.user,
list: [1, 2, state.count]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth mentioning here that while this is "correct" in the eyes of this rule, it is still problematic for performance.

@DianaSuvorova
Copy link
Owner Author

need to make sure this case is flagged correctly as well.

const mapStateToProps = (state) => (
  {
    aProp: state.aProp,
    constProp: []
  }
);

Update error msg to remove comma:

constant arrays, and objects should be initialized outside of mapStateToProps

@DianaSuvorova
Copy link
Owner Author

DianaSuvorova commented Mar 20, 2018

@lencioni I am going to call it a feature and close #20. Thanks a lot for the idea and let me know if you have more on improving this plugin.

Thanks,
Diana

@DianaSuvorova DianaSuvorova merged commit 9eb37e6 into master Mar 20, 2018
@ljharb ljharb deleted the preferHoisted branch March 20, 2018 17:45
@lencioni
Copy link

Thanks for implementing it so quickly! 💖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants