kirill-konshin / next-redux-wrapper

Redux wrapper for Next.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

impact on performance when store rerenders on every request.

wibed opened this issue · comments

commented

based on:
https://stackoverflow.com/questions/74888537/proper-way-of-using-redux-and-rtkq-in-nextjs-with-code-splitting

i assume the wrapper reloads the whole configuration on any request the store does some form of mutation.

I'd like to know whether anyone has tried and succeeded in implementing redux code splitting using RTK, RTKQ and NextJs. Also, I would like to ask an addition question: Is it necessary? What I mean by this is, if I were to not code-split at all, and send all slices on every request, how performance impactful would this be? Also, since I'm not sure exactly how the NextJs bundler works and how code chunking is done: If a certain page receives a slice it doesn't use at all, will it only receive its initial state or all of its logic (all the selectors, reducers and actions)? If not then maybe this isn't so bad, since initial states are just empty objects.

A guess in the blind but generally as you use combineReducers for when setting up the store all of the initial state and the code you are importing via that is part of the page load
So I would assume that those initial state objects are there but should ideally be more or less empty and filled from SSR based on the context of this page so ideally not affect other pages too much

The code that you import in your reducers though will be not split from what I see in my projects with redux toolkit as it is necessary to create the full store once

But just what I notice with my projects
Ideally the state and code inside reducers should be minimal compared to actual application logic