Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Redux Toolkit · Module

adapter.updateOne

adapter.updateOne changes one existing entity in a normalized Redux Toolkit entity state. It identifies the entity with id and shallowly applies the fields in changes.

How it works

adapter.updateOne updates an existing entity in a normalized entity state. Provide the target ID and a changes object; the supplied fields are shallowly merged into that entity.

Syntax

updateOne<S extends EntityState<T>>(state: S, update: Update<T>): S
updateOne<S extends EntityState<T>>(state: S, update: PayloadAction<Update<T>>): S

Parameters

NameTypeDescription
stateEntityState<T>Entity state being updated; it must contain the adapter's normalized IDs and entity lookup table.
updateUpdate<T>An object with the target entity ID and a shallow field-update map.

Returns

The updated entity state (S).

Key points

  • Pass an object containing the entity's identifier and a changes map.
  • Put every top-level field to modify inside changes; omitted fields remain unchanged.
  • The matching entity receives a shallow merge of the supplied changes.
  • The adapter method supports more than one reducer integration style.
  • Use updateOne directly as a slice or standalone reducer case when its action payload matches the expected update shape.

Common mistakes

  • Updates are shallow, so changing a nested object replaces that entire nested object rather than merging its inner fields.
  • Prefer flat entity shapes when relying on adapter updates; nested structures require care to avoid unintentionally replacing data.

Example: Update one normalized entity

import { createEntityAdapter, createSlice } from '@reduxjs/toolkit'

type User = { id: number; name: string; active: boolean }

const usersAdapter = createEntityAdapter<User>()
const usersSlice = createSlice({
  name: 'users',
  initialState: usersAdapter.getInitialState(),
  reducers: {
    userRenamed: (state, action: { payload: { id: number; name: string } }) => {
      usersAdapter.updateOne(state, {
        id: action.payload.id,
        changes: { name: action.payload.name },
      })
    },
  },
})

const state = usersAdapter.addOne(usersAdapter.getInitialState(), {
  id: 1, name: 'Ada', active: true,
})
usersSlice.reducer(state, usersSlice.actions.userRenamed({ id: 1, name: 'Grace' }))

Creates normalized user state and shallowly changes one existing user's name.

When to use it

Handle partial entity edits

A slice reducer receives an action containing an entity ID and changed fields.

Update a single lookup-table entry

A normalized collection needs one existing record changed without rebuilding the collection.

Apply adapter CRUD logic inside reducers

An entity adapter is used with Immer-powered Redux Toolkit reducers.

Interview questions

QWhat does updateOne accept and do?

It takes an update object containing an entity ID and a changes object with one or more new field values. It performs a shallow update on the matching entity.

Follow-up: What happens if changes contains a nested object? The nested value is replaced as a whole because the merge is shallow.

QHow can an entity adapter's updateOne be used?

The method can be used as a case reducer in createSlice or createReducer. It can also be called as a mutating helper inside those Immer-powered reducers.

Follow-up: Why is direct mutation acceptable there? Redux Toolkit uses Immer in those reducer contexts, translating draft mutations into immutable updates.

QWhat shape should the update object have?

The update payload has the shape { id, changes }, where id identifies the entity and changes contains fields to overwrite. Only the specified top-level fields are changed.

Follow-up: How would you update a nested field safely? Construct a replacement nested object containing the retained values, or perform a more explicit draft mutation.

  • createEntityAdapter
  • updateMany
  • upsertOne
  • upsertMany
  • EntityState
  • Update

Source: createEntityAdapter. Checked 2026-10-15.