47
rated 0 times
[
49]
[
2]
/ answers: 1 / hits: 6939
/ 4 Years ago, mon, march 16, 2020, 12:00:00
I'm creating a simple custom component that will set dynamic height and width within text.
Class CustomComponent extends React.Component{
render(){
if(this.props.children){
if(this.state.isLoading){
console.log(this.props.children)
//Here i want to know what JSX is passing
return(
<View>
<ActivityIndicator size={'large'}/>
</View>
)
}
return(
<ImageBackground
source={this.props.source}
>
{this.props.children}
</ImageBackground>
)
} else if(this.state.isLoading){
return(
<View>
<ActivityIndicator size={'large'}/>
</View>
)
} else return(
<Image
source={this.props.source}
/>
)
}
}
//Use with text
<CustomComponent>
<View>
<Image {passing image} />
<Text>Sample</Text>
</View>
</CustomComponent>
But now i need to handle if the children
only passing <Images/>
with <Text>
or not, any suggestion?
More From » reactjs