Please allow contain children, Thank you!
Children support was a feature deliberately removed in this commit to keep the API close to that of
In other words, it's unlikely it'll be added again.
We could add a ImageBackground Component. (https://facebook.github.io/react-native/docs/images.html#background-image-via-nesting)
In the meantime you can implement your own based on https://github.com/facebook/react-native/blob/8547b7e11163d545b7b99d4bdd063ef71129d62c/Libraries/Image/ImageBackground.js
Here is the component I use:
import React, { Component } from 'react'
import { View, StyleSheet } from 'react-native'
import FastImage from 'react-native-fast-image'
export default class ImageBackground extends Component {
render() {
const { children, style = {}, imageStyle, imageRef, ...props } = this.props
return (
<View style={style} ref={this._captureRef}>
<FastImage
{...props}
style={[
StyleSheet.absoluteFill,
{
width: style.width,
height: style.height,
},
imageStyle,
]}
/>
{children}
</View>
)
}
}
It supports children now. I was sort of flip flopping on how exactly to implement it for a bit.
Hello,
the problem is that "justifyContent" style property does not work for children.
I want to display children at the bottom of the image background by setting justifyContent : "flex-end", but it is not taken into account.
Do you know why ?
@appli-intramuros were you able to make it work? I am facing the exact same issue
@subhamagr I did not find any solution ...
@appli-intramuros, @subhamagr, justifyContent: 'flex-end' is working for me
@n1ru4l your method works like a charm, thank you good Sir!
Most helpful comment
We could add a ImageBackground Component. (https://facebook.github.io/react-native/docs/images.html#background-image-via-nesting)
In the meantime you can implement your own based on https://github.com/facebook/react-native/blob/8547b7e11163d545b7b99d4bdd063ef71129d62c/Libraries/Image/ImageBackground.js
Here is the component I use: