Ad

Concatenation Variable In React Native

- 1 answer

With React Native and API, I have forum.color.slug variable that is "blue".

/global.js :

global.bg_blue = '#3cb44b';
global.bg_text_blue = '#fff';
global.border_blue = '#3cb44b';

/Components/Forum/ForumIndex.js :

...
import '../../global.js'

...
<Text style={{color: 'bg_' + forum.color.slug }}/>

But it does not work, I think that the concatenation of the variable 'bg_' + forum.color.slug does not work

Ad

Answer

Have you tried:

`bg_${forum.color.slug}`
Ad
source: stackoverflow.com
Ad