Grokking React Native
0% completed
Comparing Redux Toolkit with Other State Management Solutions
Three tools can hold the same cart, and one small test shows the main difference between them. In each version below, CartCount displays the number of items, and a press applies a coupon, which does not change that number.
Context:
function CartCount() { const { items } = useContext(CartContext); return <Text>Items: {items.length}</Text>; }
Redux Toolkit:
function CartCount() { const count = useSelector((state) => state.cart.items.length); return <Text>Items: {count}</Text>; }
Zustand, a small state library, which you install with
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%