Thallysson Klein
Thallysson Klein

Reputation: 167

Props (style) aren't be passed to children

I have this component

enter image description here

And i'm trying to apply background:

enter image description here

Someone know why background isn't appearing?

Upvotes: 0

Views: 75

Answers (2)

vijay krishna
vijay krishna

Reputation: 524

Please change your BorderLayout to below format.

 return (
    <View style={[styles.parent,props.style]}>
       /* remaining code */
    </View>
)

You don't need to use flatten as View takes an array of styles as input. By following approach, BorderLayout default styles can be overridden by using style prop.

Changes made: moved props.style to the end of the array so that it'll override default styles (in your case backgroundColor).

Upvotes: 1

Sennen Randika
Sennen Randika

Reputation: 1646

In your BorderLayout,

return(
  <View style={props.style}>
    //rest implementation
  </View>
)

Please make sure that you have removed props.style from StyleSheet.flatten(...)

Upvotes: 0

Related Questions