question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New Feature: optionally pass an array or string instead of `mapStateToProps`

See original GitHub issue

Currently I am using recompose in every place where I am using connect. my mapStateToProps is essentially always:

connect(({apples, bananas, carrots, daikon}) => ({apples, bananas, carrots, daikon}))

I would like to get your thoughts on passing:

connect(["apples", "bananas", "carrots", "daikon"])

Is this an idea worth implementing? Is there an existing way to cut this extra code out? Am I just super off on this pattern?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
markeriksoncommented, May 9, 2018

@franciscop-invast : that’s almost always a bad idea, because of performance. Your component will now re-render every time an action is dispatched and the store is updated, rather than just when the data this component actually needs has changed.

0reactions
franciscop-invastcommented, May 10, 2018

@markerikson woah, that is awesome to know, than you! I have a fairly thin state tree (but deep) so I haven’t seen any difference so far, but I’ll definitely keep it into mind for the future.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Defining and Using React Redux mapStateToProps Function
The React Redux's mapStateToProps has 2 parameters. The first is the state and the second is an optional ownProps parameter.
Read more >
Connect: Extracting Data with mapStateToProps - React Redux
It should take a first argument called state , optionally a second argument called ownProps , and return a plain object containing the...
Read more >
javascript - Should I use useselector/useDispatch instead of ...
It has to be declared only within a functional component. · During declaration, it can not be inside any conditional block . Sample...
Read more >
A beginner's guide to Redux - freeCodeCamp
mapStateToProps is a function which simply returns an object that defines what state should be passed into the component by assigning values in ......
Read more >
getting-started – React Localize Redux Documentation
You can also pass Translate a function as it's child that returns the elements you want to ... The order of the translation...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found