React-native: ImageBackground don't accept resizemode style (Image does)

Created on 9 Jul 2017  Â·  3Comments  Â·  Source: facebook/react-native

I upgraded to version 0.46 and implemented ImageBackground instead of Image but now I can't use resizemode anymore in the styling.

I can't find any docs on the website regarding the ImageBackground

Is it a bug or name change of the property?

Locked

Most helpful comment

Like @Norfeldt, I ran into this issue but was unable to find any reference to actual usage in the aforementioned release notes or docs. Having discovered a solution, I'm adding the following to expand directions for future travelers beyond 'RTFD':

Per https://github.com/facebook/react-native/blob/dc97e3fb4e1a297d18b9361710290468060626fc/Libraries/Image/ImageBackground.js, ImageBackground accepts two style props – style and imageStyle – which are (obviously) applied to the internal View and Image respectively. It's also worth noting that height and weight values from the container style are applied to the image style automatically.

All 3 comments

Like @Norfeldt, I ran into this issue but was unable to find any reference to actual usage in the aforementioned release notes or docs. Having discovered a solution, I'm adding the following to expand directions for future travelers beyond 'RTFD':

Per https://github.com/facebook/react-native/blob/dc97e3fb4e1a297d18b9361710290468060626fc/Libraries/Image/ImageBackground.js, ImageBackground accepts two style props – style and imageStyle – which are (obviously) applied to the internal View and Image respectively. It's also worth noting that height and weight values from the container style are applied to the image style automatically.

Feel free to send a PR to the docs - they're hosted on this repo.

Was this page helpful?
0 / 5 - 0 ratings