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

Redux Toolkit · Module

adapter.removeOne

adapter.removeOne removes one entity from an entity adapter's normalized state by ID. It can be used directly as a case reducer or called as an adapter helper.

How it works

removeOne is a CRUD reducer generated by createEntityAdapter. It accepts one entity ID, either directly as a reducer argument or through an action payload when used as a case reducer, and removes the matching entry if present.

Syntax

removeOne<S extends EntityState<T>>(state: S, key: EntityId): S
removeOne<S extends EntityState<T>>(state: S, key: PayloadAction<EntityId>): S

Parameters

NameTypeDescription
stateEntityState<T>The normalized entity state managed by the adapter.
keyEntityId | PayloadAction<EntityId>The identifier of the entity to remove, or an action whose payload contains that identifier.

Returns

The updated entity state, with the matching entity removed when it exists.

Key points

  • It targets exactly one entity by ID and leaves state unchanged when no matching entity exists.
  • The direct TypeScript form takes an entity state plus an EntityId and returns the resulting state.
  • A payload-action overload allows the function to be used directly as a slice or reducer case reducer.
  • The method operates on the adapter's normalized entity collection rather than an arbitrary array.
  • Attach adapter.removeOne directly as a reducer definition when the action payload is the entity ID.
  • It belongs to the adapter's generated add, update, and remove CRUD reducer set.

Common mistakes

  • When calling it manually, pass an Immer Draft state if you expect the helper to mutate that state; otherwise use the returned state.
  • As a slice case reducer, provide the ID in action.payload, not as a separately named action field.

Example: Remove one entity from a slice

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

type Todo = { id: string; text: string }

const todosAdapter = createEntityAdapter<Todo>()
const todosSlice = createSlice({
  name: 'todos',
  initialState: todosAdapter.getInitialState(),
  reducers: {
    todoDeleted: todosAdapter.removeOne,
  },
})

const nextState = todosSlice.reducer(
  todosAdapter.addOne(todosAdapter.getInitialState(), { id: '1', text: 'Read docs' }),
  todosSlice.actions.todoDeleted('1'),
)

console.log(nextState.entities['1'])

The generated reducer is attached directly to a slice and removes the entity whose ID is supplied in the action payload.

When to use it

Direct case reducer

A slice action needs to delete one normalized record by its identifier.

Composed reducer logic

A reducer already has an Immer draft and needs to remove a record during custom logic.

Manual state update

Application code needs the adapter's state transformation outside a slice case reducer.

Interview questions

QWhat does removeOne do?

removeOne is generated by an entity adapter and removes one entity from normalized state using its ID. It does nothing when that ID is not present.

Follow-up: How does it receive the ID in a slice? The generated reducer reads the ID from action.payload.

QWhat are its supported call signatures?

Its direct signature accepts an entity state and an EntityId, returning the resulting entity state. It also has an overload that accepts a PayloadAction<EntityId>, which lets it serve directly as a case reducer.

Follow-up: What is the related operation for several IDs? removeMany accepts an array of IDs and removes each matching entity.

QHow can removeOne be integrated into reducers?

The adapter's CRUD methods can be passed directly to createReducer or createSlice. They can also be called manually as mutating helpers when the state value is an Immer draft.

Follow-up: Why does the draft condition matter? Immer can turn draft mutations into the next immutable state, while a normal object must be handled through the helper's returned value.

  • createEntityAdapter
  • EntityState
  • EntityId
  • removeMany
  • removeAll
  • createSlice
  • createReducer

Source: createEntityAdapter. Checked 2026-10-15.