🎥 Make videos programmatically with React
refactor(example): one useEffect on Lottie examples
Arthur Dennerbecfb93694a3
diff --git a/packages/example/src/Lottie/ExplodingBird/index.tsx b/packages/example/src/Lottie/ExplodingBird/index.tsxindex 2addd5f928..4943c82dab 100644--- a/packages/example/src/Lottie/ExplodingBird/index.tsx+++ b/packages/example/src/Lottie/ExplodingBird/index.tsx@@ -40,14 +40,11 @@ const LottieExplodingBird = () => {Promise.all([fetch(paths.bird).then((res) => res.json()),fetch(paths.end).then((res) => res.json()),- ]).then(([bird, end]) => setAnimationData({bird, end}));- }, []);-- useEffect(() => {- if (animationData) {+ ]).then(([bird, end]) => {+ setAnimationData({bird, end});continueRender(handle);- }- }, [animationData, handle]);+ });+ }, [handle]);// Get the markers and frames from the dataconst markers = animationData?.bird?.markers;diff --git a/packages/example/src/Lottie/Halloween/Pumpkin.tsx b/packages/example/src/Lottie/Halloween/Pumpkin.tsxindex 117b578f8c..00e08a4be4 100644--- a/packages/example/src/Lottie/Halloween/Pumpkin.tsx+++ b/packages/example/src/Lottie/Halloween/Pumpkin.tsx@@ -31,14 +31,11 @@ const Pumpkin = () => {// Credits: https://lottiefiles.com/37789-scary-halloween-pumpkinfetch('https://assets2.lottiefiles.com/packages/lf20_c5izbrx1.json').then((res) => res.json())- .then(setAnimationData);- }, []);-- useEffect(() => {- if (animationData) {- continueRender(handle);- }- }, [animationData, handle]);+ .then((data) => {+ setAnimationData(data);+ continueRender(handle);+ });+ }, [handle]);if (!animationData) {return null;