question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Callback doesn't return anything [🐛]

See original GitHub issue

Description

I’ll have launchImageLibrary and launchCamera running and they open the photo picker or the camera, but once I select the photo and return to the application the callback doesn’t run.

code calling image picker

  uploadPicture = () => {
    console.log("uploadPicture running");
    launchImageLibrary(
      {
        mediaType: 'photo',
        includeBase64: true,
      },
      (response) => {
        console.log(response, "image picker response");
        if (response.didCancel) {
          console.log('User cancelled image picker');
        } else if (response.errorCode) {
          console.log('ImagePicker Error: ', response.errorMessage);
        } else {
          console.log("image Picker worked!")
        }
      }
    );
  }

Solution

What needs to be done to address this issue?

Additional Information

Additional Information Image Picker version: [“react-native-image-picker”: “^3.3.2”] React Native version: [“react-native”: “0.63.4”,] Platform: [Android]

Android Logs

2021-03-18 12:01:01.092 13495-13495/com.app.test D/ViewRootImpl@b4ddbcb[MainActivity]: ViewPostIme pointer 0
2021-03-18 12:01:01.195 13495-13495/com.app.test D/ViewRootImpl@b4ddbcb[MainActivity]: ViewPostIme pointer 1
2021-03-18 12:01:01.208 13495-13873/com.app.test I/ReactNativeJS: uploadPicture running
2021-03-18 12:01:01.262 13495-13495/com.app.test D/SensorManager: unregisterListener ::   
2021-03-18 12:01:01.278 13495-13495/com.app.test D/ViewRootImpl@b4ddbcb[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0
2021-03-18 12:01:03.233 13495-13873/com.app.test I/ReactNativeJNI: Memory warning (pressure level: TRIM_MEMORY_UI_HIDDEN) received by JS VM, ignoring because it's non-severe
2021-03-18 12:01:03.248 13495-13729/com.app.test D/OpenGLRenderer: eglDestroySurface = 0x7e4fb9eca0
2021-03-18 12:01:03.254 13495-13495/com.app.test D/ViewRootImpl@b4ddbcb[MainActivity]: Relayout returned: old=[0,0][1080,2220] new=[0,0][1080,2220] result=0x5 surface={valid=false 0} changed=true
2021-03-18 12:01:03.377 13495-13495/com.app.test D/ViewRootImpl@b4ddbcb[MainActivity]: Relayout returned: old=[0,0][1080,2220] new=[0,0][1080,2220] result=0x1 surface={valid=false 0} changed=false
2021-03-18 12:01:07.721 13495-13495/com.app.test D/ViewRootImpl@b4ddbcb[MainActivity]: Relayout returned: old=[0,0][1080,2220] new=[0,0][1080,2220] result=0x1 surface={valid=false 0} changed=false
2021-03-18 12:01:07.737 13495-13495/com.app.test D/SensorManager: registerListener :: 1, LSM6DSL Accelerometer, 66667, 0,  
2021-03-18 12:01:07.759 13495-13495/com.app.test V/Surface: sf_framedrop debug : 0x4f4c, game : false, logging : 0
2021-03-18 12:01:07.759 13495-13495/com.app.test D/ViewRootImpl@b4ddbcb[MainActivity]: Relayout returned: old=[0,0][1080,2220] new=[0,0][1080,2220] result=0x7 surface={valid=true 542774386688} changed=true
2021-03-18 12:01:07.768 13495-13729/com.app.test D/OpenGLRenderer: eglCreateWindowSurface = 0x7e4fb9eca0
2021-03-18 12:01:07.809 13495-13495/com.app.test D/ViewRootImpl@b4ddbcb[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1
2021-03-18 12:01:07.824 13495-13495/com.app.test V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@22c0f42 nm : com.app.test ic=null
2021-03-18 12:01:07.824 13495-13495/com.app.test I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:6
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

11reactions
TSB1999commented, May 22, 2021

Hey - having the same problem. Using m1 also

2reactions
TSB1999commented, Jun 16, 2021

Just use react-native-crop-image-picker. Better solution anyways. https://github.com/ivpusic/react-native-image-crop-picker

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not able to return value even with callback function
Yes, you called foo correctly until you tried to return something. Returning isn't really a concept that applies to callback functions.
Read more >
Callback doesn't return anything - Dash Python
A bool prop needs a bool value - if you need to control is_open as well as what content is displayed in output-state...
Read more >
Callback Hell
Callback Hell. A guide to writing asynchronous JavaScript programs. What is "callback hell"? Asynchronous JavaScript, or JavaScript that uses callbacks, ...
Read more >
How to Handle Async Callbacks in JavaScript...Without ...
I thought it was a great question, and it seems my brain doesn't work ... I want to return that, but how can...
Read more >
callback-return - ESLint - Pluggable JavaScript Linter
To prevent calling the callback multiple times it is important to return anytime the callback is triggered outside of the main function body....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found