Marco Martin
Marco Martin

Reputation: 185

Expected "," on inline css styling

I have a dumb styling compile error.. Can anyone tell me the correct syntax... Here is my code...

<TouchableOpacity style={{marginRight:40}} onPress={() => this.handleBlueSelection}>
    <View style={this.state.blue_selected ? {styles.team_selected} : {null}}>
        <Image style={{height:30, width:30}} source={require('../../assets/images/blue.png')} />
    </View>
</TouchableOpacity>

Here is the error:

TransformError SyntaxError: C:\edit_profile.js: Unexpected token, expected "," (294:54)

I know is a dumb question but cannot find the correct syntax..

Thanks

Upvotes: 0

Views: 102

Answers (1)

Danny Buonocore
Danny Buonocore

Reputation: 3777

<View style={this.state.blue_selected ? {styles.team_selected} : {null}} >

styles.team_selected and null don't need braces around them. The reason the other style requires them is because you need to pass an object of styles (the first pair is to denote js, the second pair constructs the style object).

Upvotes: 3

Related Questions