New Feature: optionally pass an array or string instead of `mapStateToProps`
See original GitHub issueCurrently 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:
- Created 6 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.
@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.