React Native Animations Should Be Fun

Rate this content
Bookmark

Are you afraid of animations? Well, you shouldn't be, React Native Reanimated got you covered. Your mobile application can share a story through animations, can help users through micro-interactions and differentiate your app from the others.

FAQ

React Native Reanimated is a library designed to handle complex animations in React Native apps. It provides tools and capabilities for creating high-performance animations, helping developers overcome common performance issues and focus on enhancing user experience through smooth and engaging animations.

Beginners can start animating in React Native by learning the basics of the React Native Reanimated library. Key concepts include using shared values to manage animated data, applying animated styles with 'useAnimatedStyle', and manipulating animation sequences with timing, spring, and decay functions.

Shared values in React Native Reanimated are used to store data that can drive animations. These values can react to changes and can be accessed from both the UI thread and the JavaScript side. They are fundamental for creating interactive and responsive animations.

The 'interpolate' function in React Native Reanimated is used to remap input values within a given range to a new output range. This function is crucial for creating smooth transitions and animations by calculating intermediate values based on the input range provided.

Experienced developers can enhance their animation skills by exploring advanced features of React Native Reanimated, experimenting with complex animation sequences, and utilizing interpolation techniques to create more dynamic and visually appealing animations.

Yes, in React Native you can animate non-style attributes using the 'useAnimatedProps' function from the Reanimated library. This allows for the animation of properties such as stroke width and path, providing more control over the animation details.

The 'useAnimatedGestureHandler' function is used to handle user gestures in animations. It allows developers to listen and respond to gesture events, integrating user interactions seamlessly into animated components in React Native applications.

React Native Reanimated addresses performance issues by running animations on the UI thread, which prevents jank and ensures smooth performance even for complex animations. This approach significantly enhances the responsiveness and fluidity of animations in mobile apps.

Catalin Miron
Catalin Miron
28 min
24 Oct, 2022

Comments

Sign in or register to post your comment.

Video Summary and Transcription

This talk is about animations in React Native, specifically focusing on React Native Reanimated. It covers the use of interpolations and extrapolations in animations, animating items in a carousel or list, sticky elements and interpolation, and fluidity and layout animations. The talk provides valuable tips and tricks for creating performant animations and explores the use of math formulas for natural movements.

1. Introduction to Animations in React Native

Short description:

Welcome to this talk about animations in React Native. Whether you're a newcomer or an experienced developer, this talk will help you learn how to animate your static UI and provide valuable tips and tricks to level up your skills. Learning by doing can be challenging, but it's a crucial part of the learning process. By expanding your knowledge through hands-on experience, you can reach new heights.

Hey, and welcome to this talk. I'm really nervous to be here in front of you. Not because I will be giving a talk, but because I'll be talking about a subject which is really close to my heart and that's animations in React Native. And animations in general. You see, I have applied with this talk because I see the struggle in this community, especially coming from newcomers that they would like to animate their static UI, but they don't know how to actually get started with. But also from experienced developers that don't know how to level up their skills.

So the goal with this talk, and by the end of this talk, if you're a newcomer, you'll know how to animate your static UI. If you're an experienced developer, you'll look at things with different eyes or from different perspectives, and I'll show you some tricks and tips that will definitely level up your skills.

We're engineers or certain developers, and we don't think that we understand something unless we can build it. In this process, I like to call it learning by doing. It's funny because a while ago I was doing a code application and I came by this amazing code by my friend Aristotle, and it's saying that for the things we have to learn before we can do them, we learn by doing them. I'm a self-taught developer and learning by doing is not a fun process. From time to time you'll struggle quite a lot. You like to give up, and you feel that you know nothing about what you're doing. But it's okay, this itself is a learning process. There's a learning curve but with incremental steps you reach the peak. Well that's because the best solution that you currently know is based on your existing knowledge and for you to expand that knowledge and learn new ways of doing it, you learn by doing it.

2. Introduction to React Native Reanimated

Short description:

The entire talk is about React Native Reanimated, which empowers developers with tools to create fast, easy, and performant animations. Shared values, derived values, animated styles, and props, interpolation, and animated reactions are the key primitives in Reanimated. Interpolation is particularly important when animating values from an input range to an output range.

The entire talk is going to be around Reanimated or React Native Reanimated. And I believe that this library, React Native Reanimated, is going to empower you with amazing tools and capabilities so you can create delightful experiences really fast, easy and performant. I believe that Reanimated opens the gates for creating amazing animations, it eliminates a lot of roadblocks and is solving 99% of performance issues and is going to let you focus more on things that matters the most, and that's creating pleasant illusions through animations and increasing user experience.

My name is Catalin Miron, I am currently helping others to succeed. You can follow more about my work, you can follow me on twitter using mironcatalin as twitter handler. So, let's start by setting up the ground foundation of this entire talk and start talking about reanimated primitives which I believe are the most critical one to master eventually. The first and by far the most important one is to use shared values. Shared values can carry data and provide a way to react to changes and also drive the animation and it's also important that it's reactive. This data is stored on the UI thread but can be also accessed from the JavaScript side as well hence the name shared. It can be a number, it can be a boolean, a string, an object, an array.

Use derived value is when you'd like to create a new value based on a shared value. In this example I'm just adding 100 to an existing shared value so whenever that value is going to change this derived value is going to change as well. Use animated style is used when a style attribute will need to update based on a shared value or this style attribute depends on a shared value. In other words it's a reactive style sheet. The counterpart of use animated style is use animated props. For non-style attributes in this example I'm animating a stroke with but I can also do it for a path. Interpolate is going to let you remap values based on an input range and output range. You can also have interpolate color is the same as interpolate but for colors as output ranges in this example I'm morphing between red and blue. Of course you can animate those shared values by using timing, spring and decay. You can delay those animations, you can repeat those animations, you can sequence them or go crazy. You can repeat reverse a sequence of animations with an initial delay. If you're using gesture handler you can also listen to some events by using useAnimate gesture handler or if you're using scroll view or flat list or any scrolling components you can use animated scroll handler and listen to those events and if you're just interested in the onScrollEvent you can use the shorthand notation and just get directly the event that's coming from that onScrollEvent. Last but not least is use animated reaction. It's useful if you'd like to set state or call some API's or do something else on the JavaScript side and how it's actually using it's receiving two different methods. One is for the preparation, it's informing the animated reaction what shared value it's interested in and the reaction of that is going to receive the result and the previous value and you can do whatever you'd like to do.

Now that we have set up the ground foundation and what are the most important primitives in my opinion that reanimated exposed, now let's talk what matters the most when coming from outside world or you'd like to animate something. In my perspective the most important one is interpolate. Interpolate is a function that will remap an animation value from an input range to an output range. And yeah it's a method, it's going to accept a shared value, it's going to accept an input range, output range. Extrapolate left and extrapolate right and in case those two extrapolations are equal you can use the shorthand notation.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

The Whimsical Potential of JavaScript Frameworks
React Summit US 2023React Summit US 2023
28 min
The Whimsical Potential of JavaScript Frameworks
Top Content
When it comes to building whimsical interfaces, React is a surprisingly capable ally. In this talk, I'll show you how I use React to orchestrate complex interactions by digging into some examples from my blog.
Emotional & Functional UI Animations in React
React Day Berlin 2022React Day Berlin 2022
28 min
Emotional & Functional UI Animations in React
Raising the Bar: Our Journey Making React Native a Preferred Choice
React Advanced Conference 2023React Advanced Conference 2023
29 min
Raising the Bar: Our Journey Making React Native a Preferred Choice
At Microsoft, we're committed to providing our teams with the best tools and technologies to build high-quality mobile applications. React Native has long been a preferred choice for its high performance and great user experience, but getting stakeholders on board can be a challenge. In this talk, we will share our journey of making React Native a preferred choice for stakeholders who prioritize ease of integration and developer experience. We'll discuss the specific strategies we used to achieve our goal and the results we achieved.
Opensource Documentation—Tales from React and React Native
React Finland 2021React Finland 2021
27 min
Opensource Documentation—Tales from React and React Native
Documentation is often your community's first point of contact with your project and their daily companion at work. So why is documentation the last thing that gets done, and how can we do it better? This talk shares how important documentation is for React and React Native and how you can invest in or contribute to making your favourite project's docs to build a thriving community
Bringing React Server Components to React Native
React Day Berlin 2023React Day Berlin 2023
29 min
Bringing React Server Components to React Native
Top Content
React Server Components are new topic in community, bunch of frameworks are implementing them, people are discussing around this topic. But what if we could use React Server Components in React Native? And bring all optimisation features that RSC allows to mobile apps? In this talk I would present what we are able to do with RSC in React Native!
Building Cross-Platform Component Libraries for Web and Native with React
React Advanced Conference 2021React Advanced Conference 2021
21 min
Building Cross-Platform Component Libraries for Web and Native with React
Top Content
Building products for multiple platforms such as web and mobile often requires separate code-based despite most of the components being identical in look and feel. Is there a way where we could use shared React component library on different platforms and save time? In this presentation I'll demonstrate one way to build truly cross-platform component library with a unique approach of using React & React Native in combination.

Workshops on related topic

How to make amazing generative art with simple JavaScript code
JS GameDev Summit 2022JS GameDev Summit 2022
165 min
How to make amazing generative art with simple JavaScript code
Top Content
WorkshopFree
Frank Force
Frank Force
Instead of manually drawing each image like traditional art, generative artists write programs that are capable of producing a variety of results. In this workshop you will learn how to create incredible generative art using only a web browser and text editor. Starting with basic concepts and building towards advanced theory, we will cover everything you need to know.
Introducing FlashList: Let's build a performant React Native list all together
React Advanced Conference 2022React Advanced Conference 2022
81 min
Introducing FlashList: Let's build a performant React Native list all together
Top Content
WorkshopFree
David Cortés Fulla
Marek Fořt
Talha Naqvi
3 authors
In this workshop you’ll learn why we created FlashList at Shopify and how you can use it in your code today. We will show you how to take a list that is not performant in FlatList and make it performant using FlashList with minimum effort. We will use tools like Flipper, our own benchmarking code, and teach you how the FlashList API can cover more complex use cases and still keep a top-notch performance.You will know:- Quick presentation about what FlashList, why we built, etc.- Migrating from FlatList to FlashList- Teaching how to write a performant list- Utilizing the tools provided by FlashList library (mainly the useBenchmark hook)- Using the Flipper plugins (flame graph, our lists profiler, UI & JS FPS profiler, etc.)- Optimizing performance of FlashList by using more advanced props like `getType`- 5-6 sample tasks where we’ll uncover and fix issues together- Q&A with Shopify team
Detox 101: How to write stable end-to-end tests for your React Native application
React Summit 2022React Summit 2022
117 min
Detox 101: How to write stable end-to-end tests for your React Native application
Top Content
WorkshopFree
Yevheniia Hlovatska
Yevheniia Hlovatska
Compared to unit testing, end-to-end testing aims to interact with your application just like a real user. And as we all know it can be pretty challenging. Especially when we talk about Mobile applications.
Tests rely on many conditions and are considered to be slow and flaky. On the other hand - end-to-end tests can give the greatest confidence that your app is working. And if done right - can become an amazing tool for boosting developer velocity.
Detox is a gray-box end-to-end testing framework for mobile apps. Developed by Wix to solve the problem of slowness and flakiness and used by React Native itself as its E2E testing tool.
Join me on this workshop to learn how to make your mobile end-to-end tests with Detox rock.
Prerequisites- iOS/Android: MacOS Catalina or newer- Android only: Linux- Install before the workshop
How to Build an Interactive “Wheel of Fortune” Animation with React Native
React Summit Remote Edition 2021React Summit Remote Edition 2021
60 min
How to Build an Interactive “Wheel of Fortune” Animation with React Native
Top Content
Workshop
Oli Bates
Oli Bates
- Intro - Cleo & our mission- What we want to build, how it fits into our product & purpose, run through designs- Getting started with environment set up & “hello world”- Intro to React Native Animation- Step 1: Spinning the wheel on a button press- Step 2: Dragging the wheel to give it velocity- Step 3: Adding friction to the wheel to slow it down- Step 4 (stretch): Adding haptics for an immersive feel
Effective Detox Testing
React Advanced Conference 2023React Advanced Conference 2023
159 min
Effective Detox Testing
Workshop
Josh Justice
Josh Justice
So you’ve gotten Detox set up to test your React Native application. Good work! But you aren’t done yet: there are still a lot of questions you need to answer. How many tests do you write? When and where do you run them? How do you ensure there is test data available? What do you do about parts of your app that use mobile APIs that are difficult to automate? You could sink a lot of effort into these things—is the payoff worth it?
In this three-hour workshop we’ll address these questions by discussing how to integrate Detox into your development workflow. You’ll walk away with the skills and information you need to make Detox testing a natural and productive part of day-to-day development.
Table of contents:
- Deciding what to test with Detox vs React Native Testing Library vs manual testing- Setting up a fake API layer for testing- Getting Detox running on CI on GitHub Actions for free- Deciding how much of your app to test with Detox: a sliding scale- Fitting Detox into you local development workflow
Prerequisites
- Familiarity with building applications with React Native- Basic experience with Detox- Machine setup: a working React Native CLI development environment including either Xcode or Android Studio
Deploying React Native Apps in the Cloud
React Summit 2023React Summit 2023
88 min
Deploying React Native Apps in the Cloud
WorkshopFree
Cecelia Martinez
Cecelia Martinez
Deploying React Native apps manually on a local machine can be complex. The differences between Android and iOS require developers to use specific tools and processes for each platform, including hardware requirements for iOS. Manual deployments also make it difficult to manage signing credentials, environment configurations, track releases, and to collaborate as a team.
Appflow is the cloud mobile DevOps platform built by Ionic. Using a service like Appflow to build React Native apps not only provides access to powerful computing resources, it can simplify the deployment process by providing a centralized environment for managing and distributing your app to multiple platforms. This can save time and resources, enable collaboration, as well as improve the overall reliability and scalability of an app.
In this workshop, you’ll deploy a React Native application for delivery to Android and iOS test devices using Appflow. You’ll also learn the steps for publishing to Google Play and Apple App Stores. No previous experience with deploying native applications is required, and you’ll come away with a deeper understanding of the mobile deployment process and best practices for how to use a cloud mobile DevOps platform to ship quickly at scale.