Reputation: 189
I am using a styles file to handle everything relating to that within my application. I am trying to set a style based off of a variable that is previously declared however I am unsure of the syntax needed.
render() {
const { params } = this.props.navigation.state;
return (
<View style={styles.${params.key}}>
</View>
);
}
The line in question is the style={styles.${params.key}} but that line is not properly compiling. Not sure on the correct syntax of this. Thanks.
Upvotes: 0
Views: 1605
Reputation: 8958
I think it's going to be something like that:
styles[params.key]
Upvotes: 3