State management, Mamo, 2024

Bringing Redux to Mamo’s dashboard

In early 2024, Mamo’s merchant dashboard had no state management library. Shared state lived in React’s useState and createContext, and that was it. I compared six options, we picked Redux Toolkit together on a call, and I added it with the payment link redesign in March 2024. By March 2025 the dashboard had 17 slices, 10 of them written by other engineers.

Stack
React, TypeScript, Redux Toolkit
My part
Researched and experimented with different options, then implemented the chosen one in complex features

What Context couldn’t do

Context is good at values that rarely change, like the signed-in merchant or the language. It gets expensive when the value changes often. Every component that reads a context re-renders when anything in it changes, even the part it doesn’t use. A form is the worst case: each keystroke in one field re-renders every field and every preview reading the same context.

That was how Verification, Expenses, Payment links and Payments held their state. It also made changes hard to trace. When a value went wrong, there was no single place that showed what changed it.

PaymentLinkPage0
Headerreads merchant0
LinkForm0
AmountFieldreads amount0
CurrencyPickerreads currency0
TitleFieldreads title0
Previewreads amount, currency, title0

Type in the amount. With Context, each keystroke re-renders 5 components.

An illustration of the problem, not Mamo’s code. Type in the amount and watch which components re-render.

Comparing six options

I wrote up React Redux, Redux Toolkit, Redux Saga, Zustand, MobX and the Context API we already had, each against the same questions. Does a component re-render only when the value it reads changes? Can the state survive a reload? How big is the community, and how much setup does it need?

Context was the only one that failed the first question. Zustand was the lightest, but its ecosystem was small and it wasn’t clear it would hold up in an app the size of the dashboard. MobX was easy to start with and harder to debug. Plain Redux needed a lot of boilerplate, which is the problem Redux Toolkit was made to solve. Saga added generators and middleware we didn’t need.

We talked it through on a call and went with Redux Toolkit.

Six state management options compared
OptionRe‑renders only what changedKeeps state on reload
Context APIWhat we hadEvery component reading it re-renders on any change, and changes are hard to trace.NoYes
React ReduxA lot of boilerplate and a steep learning curve.YesYes
Redux ToolkitChosenCan be more than a small app needs.YesYes
Redux SagaGenerators and middleware: more than we needed.Not on its own: it’s middleware for ReduxNot on its own: it’s middleware for Redux
ZustandA small ecosystem, and may not suit a large, complex app.YesYes
MobXHarder to debug, and harder to scale as the app grows.YesYes
From my comparison doc, February 2024.

Starting with one slice

I didn’t migrate the app in one go. Redux came in with the redesign of the create payment link flow in March 2024: one store and one slice for the form. A slice holds a piece of state and the functions that change it, and each component picks only the values it needs with useSelector. That is what fixes the re-render problem: the amount field and the preview subscribe to the amount, and the title field doesn’t.

The form was the right place to start: it had the most fields reading the same state, and the redesign couldn’t meet its UX requirements without shared state.

formSlice.ts
const formSlice = createSlice({  name: 'form',  initialState: { amount: '', currency: 'AED', title: '' },  reducers: {    setAmount(state, action: PayloadAction<string>) {      state.amount = action.payload    },  },})
AmountField.tsx, TitleField.tsx
// AmountField re-renders when the amount changesconst amount = useSelector((s: RootState) => s.form.amount) // TitleField doesn't: it only reads the titleconst title = useSelector((s: RootState) => s.form.title)
A simplified version of the pattern, not Mamo’s code.

How it spread

Other engineers started writing slices for their own features about six weeks later: tables, cards, sign-up, accounting settings. I moved Verification and the expense details page over, and added slices for the global banners, permissions and the navigation. I moved to design in August 2024, and the team kept adding slices after that.

Context didn’t go away, and it didn’t need to. It stayed for small, local state. The store took the state that many components share.

17 slices between March 2024 and March 2025: 7 written by me, 10 by other engineers. I moved to design in August 2024; other engineers added five more after that.

Each dot is a slice, placed by the month it was added to the codebase.

Would I pick it again?

Probably not. Better tools have come along since. But for our use case, with what was around in early 2024, it was the best fit we had.