Le Moi
Le Moi

Reputation: 1025

React/Redux - Do I store mapped values of Redux items in Redux or Component state?

I have an app whereby users list transactions made within a calendar month. These transactions are stored in a Redux store. I need to map over these to display an accumulated value for all the transactions, but I am not sure whether this needs to be stored in Redux, or in React component state?

I am thinking this could just be React component state, but as I am learning React/Redux, I'm not to sure.

Thanks

Upvotes: 1

Views: 132

Answers (1)

Alexander Davydov
Alexander Davydov

Reputation: 395

As accumulated value will change as more transactions are added, you should recalculate it on each store update and as updating stores should re-render your component, you should probably calculate it in render function of your component.

Check out Best Practices for Component State in React.js

Upvotes: 2

Related Questions