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

Published: (March 18, 2026 at 08:47 PM EDT)
2 min read
Source: Dev.to

Source: Dev.to

Cover image for I Finally Understood How to Pass Multiple Values in Redux Toolkit (The Right Way)

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.amount
  • action.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.

0 views
Back to Blog

Related posts

Read more »

Stop Rewriting This React Form UX Logic

markdown !Cover image for Stop Rewriting This React Form UX Logichttps://media2.dev.to/dynamic/image/width=1000,height=420,fit=cover,gravity=auto,format=auto/ht...