Add Stunning Animations to Your React Native Apps with Lottie

In the dynamic world of mobile app development, user engagement and retention reign supreme. In a landscape where attention spans are fleeting, developers are constantly seeking innovative ways to captivate users and deliver memorable experiences. This is where Lottie animations step into the limelight, offering a gateway to seamless, eye-catching animations that breathe life into your React Native applications.

Gone are the days of static interfaces that fail to enthrall users. Lottie, developed by Airbnb, has emerged as a game-changer by allowing developers to effortlessly integrate intricate animations into their apps without sacrificing performance or design integrity. Whether you're a seasoned developer or just beginning your journey into the world of React Native, understanding how to harness the power of Lottie can elevate your projects to new heights.

In this blog post, we'll dive into quickly getting started with Lottie animations in a React Native Expo App.

Before we get started, do not forget to show your support!

Subscribe:

Youtube

Support:

https://www.buymeacoffee.com/mmshilleh

Step 1-) Install the Package

npm i lottie-react-native

Step 2-) Create a Lottie Files Account

  • Create an account for free https://lottiefiles.com/
  • Download the following animation as a json file https://lottiefiles.com/animations/done-BezVd9SE1f
  • Place the JSON in the assets folder of your React Native application

    Step 3-) Run the following Code

    import React, { useState } from 'react';
    import { View, TextInput, Button, StyleSheet, Text } from 'react-native';
    import LottieView from 'lottie-react-native';
    
    const FormScreen = () => {
      const [submitted, setSubmitted] = useState(false);
    
      const handleSubmit = () => {
        setSubmitted(true);
      };
    
      return (
        <View style={styles.container}>
          {!submitted ? (
            <View style={styles.formContainer}>
              <TextInput style={styles.input} placeholder="Name" />
              <TextInput style={styles.input} placeholder="Email" />
              <Button title="Submit" onPress={handleSubmit} />
            </View>
          ) : (
            <View style={{alignItems: 'center'}}>
             <Text style={{top: 200, fontSize: 20, fontWeight: 'bold'}}>Thank You For Submitting</Text> 
              <LottieView
                source={require('./assets/animation.json')}
                autoPlay
                loop={false}
                style={{flexGrow: 1, width: 400}}
              />
            </View>
          )}
        </View>
      );
    };
    
    const styles = StyleSheet.create({
      container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
      },
      formContainer: {
        width: '80%',
      },
      input: {
        height: 40,
        borderColor: 'gray',
        borderWidth: 1,
        marginBottom: 10,
        padding: 8,
      },
    });
    
    export default FormScreen;

    In reality, you can download any JSON file you want and style it as you like. This is Lottie animations in their simplest form. There are a lot of features in Lottie files but some of them are unfortunately premium options. Many of the use cases are covered by the free version so hopefully, it covers your use cases!

    Conclusion

    Hope you were able to get it to work in your app. For more details watch the video on Youtube and do not forget to subscribe. Let me know if you have any questions.

    Create a free account to access full content.

    All access to code and resources on ShillehTek.

    Signup Now

    Already a member? Sign In

    Explore More on Our Blog

    How to Create a Time-Lapse Video with a Raspberry Pi Camera

    How to Create a Time-Lapse Video with a Raspberry Pi Camera

    Learn how to make a timelapse with your Raspberry Pi in Python.

    How to Integrate the MPU6050 with the STM32 Blue Pill

    How to Integrate the MPU6050 with the STM32 Blue Pill

    Learn how to measure acceleration with the STM32 and the MPU6050 in the Arduino IDE.

    Getting Started with STM32 Blue Pill in Arduino IDE Using a USB to TTL Converter — Write Your First Program

    Getting Started with STM32 Blue Pill in Arduino IDE Using a USB to TTL Converter — Write Your First Program

    This comprehensive tutorial will guide you through the process of setting up and programming the STM32 Blue Pill...

    Automate Task Scheduling in AWS with Lambda, Step Functions, and CloudWatch

    Automate Task Scheduling in AWS with Lambda, Step Functions, and CloudWatch

    In this tutorial, I'll show you how to automatically schedule tasks in AWS at regular intervals using AWS...

    Implementing Google reCAPTCHA in a Simple React and Node.js App

    Implementing Google reCAPTCHA in a Simple React and Node.js App

    Learn how to protect your React applications from bots and spam with Google reCAPTCHA integration! This step-by-step tutorial...

    AWS Lambda Tutorial: Using Selenium with Chromedriver in Python

    AWS Lambda Tutorial: Using Selenium with Chromedriver in Python

    In this tutorial, I will guide you through the process of running Selenium with ChromeDriver inside an AWS...

    How to Connect MLX90614 Infrared Thermometer to Raspberry Pi Pico W: MicroPython Tutorial!

    How to Connect MLX90614 Infrared Thermometer to Raspberry Pi Pico W: MicroPython Tutorial!

    Learn how to use the MLX90614 with the Raspberry Pi Pico W and get infrared values in MicroPython.

    Raspberry Pi Pico/Pico W Free Simulator

    Raspberry Pi Pico/Pico W Free Simulator

    Discover how to simulate Raspberry Pi Pico projects using Wokwi, a free online simulator for Arduino and MicroPython....

    Interfacing the MPU6050 with Raspberry Pi Pico W in C++

    Interfacing the MPU6050 with Raspberry Pi Pico W in C++

    Interface with the MPU6050 using the Raspberry Pi Pico W in C++.

    How to Write your First C++ Program on the Raspberry Pi Pico W

    How to Write your First C++ Program on the Raspberry Pi Pico W

    Write your first C++ Program on the Pico W in a few simple steps.

    Back to blog

    Leave a comment

    Please note, comments need to be approved before they are published.