State Normalization

React Native 7 min min read Updated: Jul 26, 2026 Advanced
State Normalization
Advanced Topic 18 of 20

State Normalization

State normalization is a technique for structuring relational or nested data in a flat, table-like format, making updates, lookups, and performance significantly more efficient in complex applications.

The Problem with Nested Data

Storing deeply nested arrays of objects, such as a list of posts each containing an array of comments, makes updating a single deeply nested item cumbersome and prone to bugs.

javascript // Nested structure (harder to update) const posts = [ { id: 1, title: 'Post 1', comments: [{ id: 101, text: 'Nice!' }] }, ];

Normalized Structure

A normalized structure stores each entity type in its own flat object, keyed by ID, along with an array of IDs to preserve ordering.

javascript const state = { posts: { byId: { 1: { id: 1, title: 'Post 1', commentIds: [101] } }, allIds: [1], }, comments: { byId: { 101: { id: 101, text: 'Nice!' } }, allIds: [101], }, };

Using createEntityAdapter in Redux Toolkit

Redux Toolkit provides createEntityAdapter, a utility that automatically generates normalized state structures along with pre-built reducers and selectors for common CRUD operations.

javascript import { createEntityAdapter, createSlice } from '@reduxjs/toolkit'; const postsAdapter = createEntityAdapter(); const postsSlice = createSlice({ name: 'posts', initialState: postsAdapter.getInitialState(), reducers: { addPost: postsAdapter.addOne, updatePost: postsAdapter.updateOne, }, });

Benefits of Normalization

  • Faster lookups by ID instead of searching through arrays
  • Easier updates without deeply nested spread operations
  • Avoids data duplication when the same entity appears in multiple places

Conclusion

Normalizing complex relational data significantly simplifies state updates and improves performance in React Native applications dealing with interconnected data like posts, comments, and users.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators