react-nativelottie

lottie-react-native is not showing


I tried many times but it's not showing. Why not? Here are my code:

import { View, Text } from 'react-native'
import React from 'react'
import LottieView from 'lottie-react-native';

const App = () => {
  return (
    <View style={{ backgroundColor: 'white', height: '100%' }}>
      <Text style={{ color: 'black' }}>Helo World</Text>
      <View style={{flex: 1, justifyContent: 'center', alignItems: 'center', width: '100%', backgroundColor: 'red'}}>
        <LottieView
          source={require('./PoliteChicky.json')}
          style={{width: '100%'}}
          autoPlay
          loop
        />
      </View>
    </View>
  )
}

export default App

Solution

  • Add this in your package.json file. I think the issue is based on the width you had given.

    "lottie-react-native": "^5.1.5",
    

    Import this in your desired file

    import LottieView from "lottie-react-native";
    

    Use the LottieView as follows in your desired page

    <LottieView
      source={images.searchloading}
      style={{ width: 100, height: 100 }}
      autoPlay
      loop
    />