0

I'm new to React Native EStyleSheet lib. I find it's really cool, but one thing that I can't figure out is, how to apply multiple styles to a single element just like I used to do with regular styles with style={{...styles.style1, ...styles.style2}}?

render() {
    return <View style={estyles.container}>
        <View style={{...estyles.container, ...estyles.containerInner}}>
            <Text>Hello, World!</View>
        </View>
    <View>

}

const estyles = EStyleSheet.create({
    container: {
        padding: '2%',
        borderStyle: 'solid',
        borderRadius: 1,
        borderWidth: 1,
        borderColor: 'black'
    },
    containerInner: {
        padding: '5%'
    }
});
Andrei
  • 42,814
  • 35
  • 154
  • 218

2 Answers2

1

You can use array of styles to apply multiple styles to single view

example

<View style={[styles.container, styles.view,...]}>
</View>
Paras Korat
  • 2,011
  • 2
  • 18
  • 36
0

you can used in style array of styles for example:

render() {
    return <View style={estyles.container}>
        <View style={[estyles.container,estyles.containerInner]}>
            <Text>Hello, World!</View>
        </View>
    <View>

}

const estyles = EStyleSheet.create({
    container: {
        padding: '2%',
        borderStyle: 'solid',
        borderRadius: 1,
        borderWidth: 1,
        borderColor: 'black'
    },
    containerInner: {
        padding: '5%'
    }
});

this => [estyles.container,estyles.containerInner] can used