---
title: "Mastering React’s Stable Values"
description: "In React, a stable value is one that keeps its identity across renders: state setters from useState/useReducer and refs from useRef are stable, while inline arrays, objects and anonymous functions are recreated on every render."
url: "https://swe.quest/articles/mastering-react-s-stable-values-0db7f81b967a1c06"
canonical: "https://shopify.engineering/master-reacts-stable-values"
source: "Shopify Engineering"
published: "2022-08-02"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 8
tags: ["react","frontend","mobile","performance"]
---

# Mastering React’s Stable Values

A post on [Shopify Engineering](https://swe.quest/sources/shopify.md), published 2022-08-02, 8 min read, Deep dive. Original: [https://shopify.engineering/master-reacts-stable-values](https://shopify.engineering/master-reacts-stable-values)

## Summary

In React, a stable value is one that keeps its identity across renders: state setters from useState/useReducer and refs from useRef are stable, while inline arrays, objects and anonymous functions are recreated on every render. Unstable values break hooks that take dependency lists (useEffect, useCallback, useMemo) and APIs like React Navigation's useFocusEffect, which will unsubscribe and resubscribe on every render unless its callback is wrapped in useCallback. Rendering an inline helper function as a JSX component makes React see a new component type each render, so it tears down and remounts the whole subtree, which is costly in React Native. The fixes are to call such helpers directly or define components at module scope, and to use useCallback selectively, mainly for props passed to React.memo components.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [React](https://swe.quest/tags/react.md) (Web & mobile)
- [Frontend](https://swe.quest/tags/frontend.md) (Web & mobile)
- [Mobile](https://swe.quest/tags/mobile.md) (Web & mobile)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)

## Prerequisites

- React hooks ([easy posts on React](https://swe.quest/tags/react.md?difficulty=easy))
- React function components ([easy posts on React](https://swe.quest/tags/react.md?difficulty=easy))

## Keywords

React, React Native, useCallback, useMemo, useFocusEffect, React Navigation, React.memo

## Related posts

- [Why I Still Use jQuery](https://swe.quest/articles/why-i-still-use-jquery-0ed39bb18f643ea2.md): Docker · 2025-10-17 · Medium · 8 min read · JavaScript, Frontend, Browsers
  jQuery remains a reasonable choice in 2025 for specific cases: maintaining legacy apps where rewrites cost more than they return, build-free prototypes loaded from a CDN, older embedded browsers like kiosks and intranets, simple chained animations, and servers that return HTML fragments, where \`.load()\` replaces fetch-plus-DOMParser boilerplate.
- [The uphill climb of making diff lines performant](https://swe.quest/articles/the-uphill-climb-of-making-diff-lines-performant-3c1abf458c8d7ced.md): GitHub Engineering · 2026-04-03 · Medium · 10 min read · Web performance, React, Frontend, Performance engineering
  GitHub rebuilt the React diff-line components in the pull request Files changed tab after large PRs pushed the JavaScript heap past 1 GB, DOM counts above 400,000 and INP to unusable levels.
- [How Migrating from Vanilla Redux to Redux Toolkit Improved State Management in Shopify POS](https://swe.quest/articles/how-migrating-from-vanilla-redux-to-redux-toolkit-improved-state-management-in-bb79ef4f578fa9c6.md): Shopify Engineering · 2023-03-31 · Medium · 8 min read · React, Refactoring & migrations, Mobile, TypeScript, Frontend
  Shopify's Point of Sale React Native app moved from vanilla Redux to Redux Toolkit over about three months.
- [How We Built the Add to Favorite Animation in Shop](https://swe.quest/articles/how-we-built-the-add-to-favorite-animation-in-shop-145e9cee56a5fe21.md): Shopify Engineering · 2022-03-25 · Medium · 7 min read · Mobile, React, Frontend
  Shop's Add to Favorite animation, where a product thumbnail pops in, scales, and drops into a bouncing heart tab-bar icon, is built in React Native with Reanimated by driving the whole sequence from a single shared progress value that steps through 1, 2, 3 and so on, each step with its own duration and easing from the motion spec.
- [Migrating to React Native's New Architecture](https://swe.quest/articles/migrating-to-react-native-s-new-architecture-ea77244bbb28fd72.md): Shopify Engineering · 2025-09-05 · Medium · 12 min read · React, Mobile, Refactoring & migrations, Deployment
  Shopify moved Shopify Mobile and POS to React Native's New Architecture (Fabric) without pausing weekly releases.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
