Using react-lottie version 1.2.3 to try animate in React web application.
It successfully compiled without any error message but the animation would not show from json file.
I have followed React Lottie not showing animation not showing (web) which suggested replace animationData: animationData
to animationData: animationData.default
. Have tried both however it did not work.
Any ideas?
import React,{Component} from 'react';
import Lottie from 'react-lottie';
import animationData from './lottie/lottie_page_not_found.json';
class PageNotFound extends Component {
render(){
const defaultOptions = {
loop: true,
autoplay: true,
animationData: animationData.default,
rendererSettings: {
preserveAspectRatio: "xMidYMid slice"
}
};
return(
<div>
<h1 style={{display: 'flex', justifyContent: 'center'}}>Page Not Found</h1>
<Lottie
options={defaultOptions}
height={400}
width={400}
/>
</div>
);
}
}
export default PageNotFound;