Description
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?
- Open https://react-redux-batching-xkhtq8.stackblitz.io/
- Open dev tools -> React profiler
- Click "reload and start profiling"
- After reload, end profiling
Expected: 2 commits:
- First render
Counter
andReduxCounter
update, triggered viadispatch
insideCounter#componentDidMount
Actual: 3 commits:
- First render
Counter
update, triggered viadispatch
insideCounter#componentDidMount
ReduxCounter
update, triggered viadispatch
insideCounter#componentDidMount
IIUC, there is no reason why 2 and 3 can not be batched into a single React re-render?
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?
Update: note this issue does not occur when using useSelector
. https://stackblitz.com/edit/react-redux-batching-zb1wxv?file=index.tsx