From a1295e09aceb3d34a68f6ec3edc43c236c1e7356 Mon Sep 17 00:00:00 2001
From: IZUMI-Zu <274620705z@gmail.com>
Date: Sun, 29 Sep 2024 17:25:40 +0800
Subject: [PATCH] feat: fix bug in icons (#29)
---
AvatarWithFallback.js | 41 ++++++++++++++++++++---------------------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/AvatarWithFallback.js b/AvatarWithFallback.js
index 32180f4..7496aac 100644
--- a/AvatarWithFallback.js
+++ b/AvatarWithFallback.js
@@ -12,31 +12,30 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-import React, {useState} from "react";
-import {View} from "react-native";
+import React from "react";
import {Image} from "expo-image";
-const AvatarWithFallback = ({source, fallbackSource, size, style}) => {
- const [hasError, setHasError] = useState(false);
-
- const handleImageError = () => {
- if (!hasError) {
- setHasError(true);
- }
- };
+function AvatarWithFallback({source, fallbackSource, size, style}) {
+ const [imageSource, setImageSource] = React.useState(source);
return (
-
-
-
+ setImageSource(fallbackSource)}
+ placeholder={fallbackSource}
+ placeholderContentFit="cover"
+ contentFit="cover"
+ transition={300}
+ cachePolicy="memory-disk"
+ />
);
-};
+}
export default AvatarWithFallback;