How does react decides when it should render the component after dispatching actions?

(Abhinav Knolskape) #1

Below is an example to help you understand my problem exactly:
Here, I am dispatching an action which updates the store everytime.
But, React only re renders the component after all the actions in this loop are completed. How does react do that?
When does it really decide that there are no further actions and it should re render the components?

for( let i = 0 ; i < 1000 ; i++ ) {

Result: component is rendered only once

(Usul Pro) #2

How looks your updateCountAction?
do you use setState or via props?

(Abhinav Knolskape) #3

updateCountAction returns an object which will change data in the store. It doesn’t use setState.

updateCountAction: function(value) {
return {
type: ‘update_count’,
This updates the store (redux store) 1000 times. The component is directly listening to the store but it renders only after all the actions are completed which is when i becomes 1000.

(Abhinav Knolskape) #4

Can you check my reply please :slight_smile: