Search⌘ K

The Second createStore Argument

Explore how the second argument of Redux createStore functions as the initial state in your application. Understand how to properly initialize and retrieve state from the Redux store, and see how this integrates with a React app's refactoring process for state management.

We'll cover the following...

When you visit the Cashier in the bank, if you asked them for your account balance, they’ll look it up and tell it to you.

widget

But how?

When you first created an account with your bank, you either did so with some amount of deposit or not.

widget

Let’s call this the initial deposit into your account.

Back to Redux.

In the same way, when you create a redux STORE (our own money keeping VAULT), there’s the option of doing so with an initial deposit.

In Redux terms, this is called the initialState of the app.

Thinking in code, initialState is the second argument passed into the createStore function call.

JavaScript (JSX)
const store = createStore(reducer, initialState);

Before making any ...