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.

facing slowness in user actions done through thunk middleware

See original GitHub issue

Hi,

Anyone facing slowness in user actions. Sometimes a user action might dispatch many actions. Every action causes rerender of react.

const setAction()=>{
return async (dispatch, getState) =>{
     await dispatch(setAction1);
      dispatch(setNormalAction1);
      dispatch(setNormalAction2);
     await dispatch(setAction2);
     await dispatch(setAction2);
}
}

I am using above pattern of actions with redux-thunk.

One option of redux-batched-subscribe in middleware helped in batching concurrent actions( setNormalAction*) and hence saved some renders. But still the performance is bad because of sequence required in thunk actions(setAction1*).

Any other approaches, you are following to scale this?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
phpeekcommented, Mar 24, 2017

No, but mine is a normal connected component with redux-thunk middleware.

Gotya.

In that case You’ll see rerender of Your component every time You dispatch an action which changes part of state that component is connected to.

What I usually do is extract logic contained in actions to methods and execute them in necessary order. Then when all data is ready, dispatching single action with this data.

This might not be the case for You, as from what I see, Your actions depend on data in state set by other actions. In that case You might consider connecting Your component to part of state that is being changed by the last dispatched action. But again, this is very dependent on the way how Your state is designed.

I would need to have more specific examples, so that I can fully understand Your use case.

This is not an issue of RSK itself, it’s just how redux works. 😉

0reactions
ulanicommented, May 27, 2021

@shishirarora3 thank you very much for crating this issue! Unfortunately, we have close it due to inactivity. Feel free to re-open it or join our Discord channel for discussion.

NOTE: The main branch has been updated with React Starter Kit v2, using JAM-style architecture.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PersistGate causing slowness · Issue #816 · rt2zz/redux-persist
In development environment, I noticed that with each reload that the app was slow. So I did some testing, and by removing PersistGate,...
Read more >
Writing Logic with Thunks - Redux
Writing logic that needs to dispatch multiple actions in a row or over time · The middle function receives the next middleware in...
Read more >
Persist state with Redux Persist using Redux Toolkit in React
When using Redux Persist without using the Thunk middleware, we'd get an error in the browser's console reading a non-serializable value was ...
Read more >
Understanding Asynchronous Redux Actions with Redux Thunk
Learn how to use the Redux Thunk middleware to run asynchronous operations, talk to an API and dispatch actions to the store.
Read more >
Very slow response from action creator React/Redux
I update one of the values of contracts in my DB, and I want redux to then dispatch the new list for the...
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