Global State

React Native 6 min min read Updated: Jul 26, 2026 Intermediate
Global State
Intermediate Topic 10 of 20

Global State

Global state refers to data that needs to be accessed or modified by many different components throughout your application, such as user authentication, theme preferences, or shopping cart contents.

Examples of Global State

  • Current logged-in user information
  • App theme (light or dark mode)
  • Shopping cart items in an e-commerce app
  • Notification counts and unread messages
  • Application-wide settings and preferences

Managing Global State with Context API

javascript const CartContext = createContext(); function CartProvider({ children }) { const [cart, setCart] = useState([]); return ( {children} ); }

Managing Global State with Redux Toolkit

javascript const cartSlice = createSlice({ name: 'cart', initialState: [], reducers: { addItem: (state, action) => { state.push(action.payload); }, }, });

Deciding What Belongs in Global State

Not all data needs to be global. A good rule of thumb is to only lift state to a global store if multiple, unrelated components genuinely need access to it.

Avoiding Overuse of Global State

Putting too much data into global state, including data that is only relevant to a single screen, can make your application harder to reason about and unnecessarily couple unrelated components.

Conclusion

Effectively managing global state, using either Context API or Redux depending on your app’s complexity, is essential for building React Native applications where data needs to flow consistently across many different screens and components.

Get Newsletter

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