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.

Nested `connect` updates are not batched

See original GitHub issue

Do you want to request a feature or report a bug?

(If this is a usage question, please do not post it here—post it on Stack Overflow instead. If this is not a “feature” or a “bug”, or the phrase “How do I…?” applies, then it’s probably a usage question.)

Bug

What is the current behavior?

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn’t have dependencies other than React. Paste the link to a CodeSandbox (https://codesandbox.io/s/new) or RN Snack (https://snack.expo.io/) example below:

https://stackblitz.com/edit/react-redux-batching-xkhtq8?file=index.tsx

What is the expected behavior?

  1. Open https://react-redux-batching-xkhtq8.stackblitz.io/
  2. Open dev tools -> React profiler
  3. Click “reload and start profiling”
  4. After reload, end profiling

Expected: 2 commits:

  1. First render
  2. Counter and ReduxCounter update, triggered via dispatch inside Counter#componentDidMount

Actual: 3 commits:

  1. First render
  2. Counter update, triggered via dispatch inside Counter#componentDidMount
  3. ReduxCounter update, triggered via dispatch inside Counter#componentDidMount

IIUC, there is no reason why 2 and 3 can not be batched into a single React re-render?

Screen Recording 2020-01-28 at 16 30 28

Which versions of React, ReactDOM/React Native, Redux, and React Redux are you using? Which browser and OS are affected by this issue? Did this work in previous versions of React Redux?

image

Update: note this issue does not occur when using useSelector. https://stackblitz.com/edit/react-redux-batching-zb1wxv?file=index.tsx

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:22 (14 by maintainers)

github_iconTop GitHub Comments

4reactions
markeriksoncommented, Feb 4, 2020

And I’m saying there’s two different aspects here:

  • Whether nested updates at the same level are batched
  • Whether nested updates at different levels are batched

We currently do the first, but not the second.

0reactions
markeriksoncommented, Dec 21, 2021

I’m going to close this as a WONTFIX for now, largely because we’re encouraging folks to stop using connect (even though it’ll be fully supported in v8). This is a real bit of behavior that I can understand is annoying, but I don’t think there’s a meaningful change we can make at this point, and I don’t intend to spend time fixing it myself.

If someone still feels strongly about this please comment, or even better file a PR to improve behavior here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Data JPA: Batch insert for nested entities - Stack Overflow
Specific to MySQL, you have to specify rewriteBatchedStatements=true as part of the connection URL. To make sure that batching is working as ...
Read more >
ServiceNow Update Set Batching - Best Practices
My opinion is that it should be able to determine which update is newer and automatically accept that one. We've been using batch...
Read more >
Batch Update Nested family Components - Autodesk Forums
So, when I update one of the nested families, let's say the base panel, ... opening and updating each one individually is NOT...
Read more >
Errror - Could not execute JDBC batch update; SQL [insert into ...
constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update org.springframework.dao.
Read more >
Prisma Client API (Reference)
Prisma Client does not yet support batch inserts at a database level. ... There are no nested queries in the upsert 's create...
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