Skip to content

[Chore] Resolve nativeEvent payload deprecation #108

Open
@jwoo92

Description

@jwoo92

Today I used patch-package to patch [email protected] for the project I'm working on.

After migrating from react-native-fast-image to expo-image, this warning indicator started to appear in my CLI:

[expo-image]: Accessing event payload through "nativeEvent" is deprecated, it is now part of the event object itself

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-image-progress/index.js b/node_modules/react-native-image-progress/index.js
index 6b60823..ee6ac8a 100644
--- a/node_modules/react-native-image-progress/index.js
+++ b/node_modules/react-native-image-progress/index.js
@@ -125,7 +125,7 @@ export const createImageProgress = (ImageComponent) =>
     };
 
     handleProgress = (event) => {
-      const progress = event.nativeEvent.loaded / event.nativeEvent.total;
+      const progress = event.loaded / event.total;
       // RN is a bit buggy with these events, sometimes a loaded event and then a few
       // 100% progress – sometimes in an infinite loop. So we just assume 100% progress
       // actually means the image is no longer loading
@@ -141,7 +141,7 @@ export const createImageProgress = (ImageComponent) =>
     handleError = (event) => {
       this.setState({
         loading: false,
-        error: event.nativeEvent,
+        error: event,
       });
       this.bubbleEvent('onError', event);
     };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions