I Finally Understood How to Pass Multiple Values in Redux Toolkit (The Right Way)
Source: Dev.to

Today was one of those small learning moments… but it completely changed how I write Redux logic.
I used to think:
- “Redux actions can only take one value”
- “If I need more data, things will get messy”
Then I learned a clean and scalable way to handle multiple values in Redux Toolkit using the prepare function.
The Problem I Faced
I was trying to dispatch an action that needed both a loan amount and a loan purpose. At first I didn’t know how to pass both values properly and considered:
- Creating multiple actions, or
- Using a complex payload structure
Both approaches felt messy and hard to maintain.
The Solution: prepare Function in Redux Toolkit
Inside createSlice you can define a prepare method that formats the payload for you.
requestLoan: {
prepare(amount, purpose) {
return {
payload: { amount, purpose },
};
},
reducer(state, action) {
if (state.loan > 0) return;
state.loan = action.payload.amount;
state.loanPurpose = action.payload.purpose;
state.balance += action.payload.amount;
},
}
What’s Happening Here?
1️⃣ prepare Handles Multiple Arguments
Instead of manually constructing an object, you can dispatch like this:
dispatch(requestLoan(5000, "Buy Car"));
prepare automatically converts it into:
payload: {
amount: 5000,
purpose: "Buy Car"
}
2️⃣ Reducer Stays Simple
The reducer no longer worries about how the payload was created; it simply accesses:
action.payload.amountaction.payload.purpose
3️⃣ Logic Feels More Professional
This approach helps you:
- Avoid messy payload creation in components
- Keep logic centralized
- Write cleaner and more readable reducers
Why This Matters
Redux Toolkit is designed to simplify complex patterns. Using prepare:
- Makes actions flexible
- Keeps reducers clean
- Improves scalability
You don’t need hacks—just the right tools.
My Key Takeaway
You don’t need multiple actions for multiple values. A well‑structured payload, created with prepare, is all you need.
Final Thoughts
This isn’t a huge feature, but it represents a big mindset shift. Redux Toolkit isn’t just about writing less code; it’s about writing smarter and cleaner code. If you’re learning Redux Toolkit, don’t overlook small features like prepare—they can make the biggest difference.