Skip to content

Commit 1692a58

Browse files
committed
fix: clear state in useImage hook
1 parent 5b9a448 commit 1692a58

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/react-native-nitro-image/src/useImage.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ export function useImage(source: AsyncImageSource): Result {
3636

3737
// biome-ignore lint: The dependencies array is a bit hacky.
3838
useEffect(() => {
39+
// clear state each time we will load a new image
40+
if (image.image || image.error) {
41+
setImage({ image: undefined, error: undefined });
42+
}
43+
3944
(async () => {
4045
try {
4146
const result = await loadImage(source);

0 commit comments

Comments
 (0)