Grokking React Native
0% completed
Best Practices & When Not to Use Context API
Ten updates to one stock price caused 500 row renders in a list of 50 rows built on Context. Each row was wrapped in memo, and that made no difference.
const Row = memo(function Row({ id }) { const prices = useContext(PriceContext); return <Text>{id}: {prices[id]}</Text>; });
The same list, with the same updates, behaved very differently when each row subscribed to its own price through a state library:
Context: 500 row renders Redux Toolkit with a selector: 10 row renders Zustand with a selector: 10 row renders
`memo
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%