JavaScript Redux: Performance of list of connected components redux list performance

I have some <List> connected component which passes a lot of attributes to <ListItem> components. It is getting to the point where a refactor is needed because too many attributes are being passed down.

Suppose I turn the table and instead make <ListItem> a connected component so that I am not required to pass so many attributes down. Would I expect to see a performance degradation or improved performance of my UI rendering?

I've done some reading but wasn't able to find an exact answer to my question.

Answer:1

Generally, connecting more components is better for performance, because the cost of running more mapState functions is less than the cost of doing more "wasted" component re-renders.

Please see the Redux FAQ entries on performance and connecting multiple components, and my blog post Practical Redux, Part 6: Connected Lists and Performance for more details.

Answer:2

You don't need to pass all the props one by one. You may use the spread operator to pass all the props at once:

<List myProp={myProp} {...rest} />

This will send one prop myProp and all other props exists in the rest props.

Or, you can pass all the props:

<List {...props} />

In the ListItem component:

const { myOtherProp1, myOtherProp2 } = props
<ListItem myOtherProp1={myOtherProp1} myOtherProp2={myOtherProp2} />

Also, you may pass the default props which you think is required for the component:

List.defaultProps = {
  myOtherProp3: 'My default prop 3'
  myOtherProp10: 'My default prop 10'
}

This way you're passing all the props but use them when you need to use them.


To answer your exact question:

No. There'll be no performance hit. There's no limit of the props. You can pass as many as you want. The receiving component will get all the props from single source props.

Answer:3

I am planning on adding the javascript Notifications API functionality to a web app I am building. I took a look at the example from the MDN site: function spawnNotification(theBody, theIcon, ...

I am planning on adding the javascript Notifications API functionality to a web app I am building. I took a look at the example from the MDN site: function spawnNotification(theBody, theIcon, ...

  1. using icon font in sketch
  2. using icon font
  3. using icon font as background image
  4. using font icon in css
  5. display icon using font

I'm working with the import function, I wish use an import like for css, I mean "import './file.css'" then all the css attributes are diffused in the file. I have tried the same with ReactJS but it ...

I'm working with the import function, I wish use an import like for css, I mean "import './file.css'" then all the css attributes are diffused in the file. I have tried the same with ReactJS but it ...

  1. import variables from another file python
  2. import variables from another file matlab
  3. import variables from scss file
  4. import variables from module python
  5. import variables from another file javascript
  6. import variables from file bash
  7. import variables from other files python
  8. import variables from a file python
  9. import variables from another file powershell
  10. import variables from text file python
  11. import variables from another class java
  12. import variables from excel to matlab
  13. import variables from another file bash
  14. import variables from settings django
  15. import variables from another python script
  16. import variables from workspace to simulink
  17. import variables from another file js
  18. import variables from another file java
  19. import variables from file powershell
  20. import variables from module

I face difficulties to write reducers for Redux. Specifically I end up wrapping a lot of my state manipulation in .map, .slice etc. When the structure of my state object grows larger, the reducers ...

I face difficulties to write reducers for Redux. Specifically I end up wrapping a lot of my state manipulation in .map, .slice etc. When the structure of my state object grows larger, the reducers ...

I have a Rails 4.2 app that is getting requests from another domain. I'd like them to send a uuid that we set in our javascript. It works on localhost but not cross-domain. In our ...

I have a Rails 4.2 app that is getting requests from another domain. I'd like them to send a uuid that we set in our javascript. It works on localhost but not cross-domain. In our ...

  1. rails cross domain cookies
  2. rails cross domain
  3. rails allow cross domain requests
  4. rails api cross domain