-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
autoBatchEnhancer - ReferenceError: requestAnimationFrame is not defined (Next.js, RTK 1.9, next-redux-wrapper) #2869
Comments
It does work when the queue type is set to export const makeStore = (context: Context) => {
const store = configureStore({
reducer: {
[api.reducerPath]: api.reducer,
[counterSlice.name]: counterSlice.reducer,
},
enhancers: (existingEnhancers) => {
return existingEnhancers.concat(autoBatchEnhancer({ type: "tick" }));
},
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({
thunk: {
// https://github.com/reduxjs/redux-toolkit/issues/2228#issuecomment-1095409011
extraArgument: context,
},
})
.prepend(listenerMiddleware.middleware)
.concat([api.middleware]),
devTools: process.env.NODE_ENV !== "production",
});
setupListeners(store.dispatch);
return store;
}; |
It's essentially a different duration to the flush of waiting low-prio actions.
In our tests, Maybe we should also polyfill |
It batches in shorter intervals, so you will see more rerenders than with You can totally use one on the server and the other on the client. |
FYI - using the devtools is awesome now!!! Thank-you for responding on a Sunday, I hope you guys get a break from all of this sometimes. While a long-term solution would be good, would it work (or should it work, or is it a stupid thing to do) to detect running server-side vs client-side and set appropriately? Although this is all going to get very interesting in the near future when the Nextjs Layouts RFC comes out of beta. In this instance I'm assuming a polyfil would be the only realistic option. So can I confirm the only downside to using |
tbh I'd really rather not add more polyfills at this point :) I know this is a bit of a different situation, but given that a goal in 2.0 is to remove polyfills, I'd rather just document the need to alter it at the store setup level. Although, thinking about it... I guess it might be something like: const rAF = (typeof window !== 'undefined' && window.requestAnimationFrame) ? window.requestAnimationFrame : queueMicrotask ugly, but workable I guess? |
Addressed in #2887 . |
Next.js fails when using the new
autoBatchEnhancer
in bothdev
mode andbuild
.I have a semi-lightweight-but-not-minimal reproduction available here: https://github.com/littlejon/rtk-19-issue-repro (based on a template I built to speed up component testing outside of my project).
I'm not sure if this is a Nextjs, next-redux-wrapper, or Redux-Toolkit issue, please let me know if there are further details I can provide or tests to try.
Thanks!
Backend Logs: dev
Build Logs
The text was updated successfully, but these errors were encountered: