Imagine having a like animation and a counter. When the like is pressed the counter should increment.
A person using the interface doesn’t know about how data flux is designed, what is a network request. The person just expects the heart to be colored immediately.
As React Native is single-threaded, the best approach is to run animation on UI Thread(color the icon + update the counter) and only when the animation is finished run on JS Thread the rest of the work as updating state and sending a network request. In this way the counter is not waiting for request, the whole interaction is on UI.
7
46 reads
CURATED FROM
IDEAS CURATED BY
TL;DR how threading is working in React Native and the solution of handling data flux for a like button and its counter
“
Read & Learn
20x Faster
without
deepstash
with
deepstash
with
deepstash
Personalized microlearning
—
100+ Learning Journeys
—
Access to 200,000+ ideas
—
Access to the mobile app
—
Unlimited idea saving
—
—
Unlimited history
—
—
Unlimited listening to ideas
—
—
Downloading & offline access
—
—
Supercharge your mind with one idea per day
Enter your email and spend 1 minute every day to learn something new.
I agree to receive email updates