0

I have a div in my React app like:

<div className="profile_image" style={{backgroundImage: 'url('+ process_image(url, function(img){ return img}) + ')'}}>

Here process_image(url, function(img){ return img}) is a function which returns image. But it does not display the image.

What is wrong ??

If I do :

process_image(url, function(img){ 
    console.log(img)
    return img
})

On doing console.log(img) it gives me the image url.

Need help

varad
  • 7,309
  • 20
  • 60
  • 112
  • `process_image` does not *return* the image. It returns nothing (as far as we know). It *fires a callback* which returns something (which goes nowhere). – deceze Sep 21 '16 at 09:56
  • Then how should I get the image from that function ?? – varad Sep 21 '16 at 10:04
  • Do the asynchronous call **in the controller**, instead of `return img` use `$scope.img = img`, and use just `img` in the template. Or something to this effect. – deceze Sep 21 '16 at 10:06

0 Answers0