Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chore] Resolve nativeEvent payload deprecation #108

Open
jwoo92 opened this issue May 15, 2023 · 0 comments
Open

[Chore] Resolve nativeEvent payload deprecation #108

jwoo92 opened this issue May 15, 2023 · 0 comments

Comments

@jwoo92
Copy link
Contributor

jwoo92 commented May 15, 2023

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);
     };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant