Simple way to do code splitting for Redux

・1 min read

Most of documentation, tutorials, youtube videos taught you how to create your own Redux Store. It's sweet. But let's make it better.

How about you want to do code splitting with your Redux store ?

By code splitting Redux store, i mean, in some cases, you don't want to import all of your Redux actions to be used in a React component, for example, on /login page, you just want to import login action only.

The solution is dead simple !

Just use the old school window.REDUX_STORE_LOGIN for /login route.

window.REDUX_STORE_LOGIN = createStore(...)

Do this when user is accessing /login route.

And do the same for all of your routes to split your Redux store to the max.

Happy reduxing!

DISCUSSION
Classic DEV Post from Jan 12

Kotlin: How Can a Programming Language be so Young And so Mature at The Same Time?

In this article, we’re going to explore why young programming languages with modern features can’t be adopted quickly. Additionally, we’re going to take a look at one exceptional example that got specific parameters right to be both young, modern and mature, just ready for adoption at small and big scale.

Truong Hoang Dung
I hate technical debts, very much. Learning to clean debt out of my life.