Shopify

How Migrating from Vanilla Redux to Redux Toolkit Improved State Management in Shopify POS - Shopify

Mar 31, 2023
How Migrating from Vanilla Redux to Redux Toolkit Improved State Management in Shopify POS - Shopify
SummaryAI, from the source post

This post details the migration of Shopify's Retail Point of Sale app from Vanilla Redux to Redux Toolkit (RTK). It outlines the decision-making process, the chosen balanced migration strategy (prioritizing stability and reuse over a full rewrite), and the implementation details. Key technical contributions include the coexistence of Vanilla Reducers and RTK Slices, the refactoring of state mutations to RTK's mutable syntax, and a hybrid approach to asynchronous logic using `createAsyncThunk` with `ThunkAPI` due to GraphQL limitations with RTK Query. It also highlights learnings such as the importance of explicit typing for `useDispatch`, `useSelector`, and `useStore`, and the necessity of using the `unwrap()` method on `dispatch` calls when awaiting.