title: How to use a variable in Style Sheet in React Native?
body: <p>I have a file named &quot;GlobalStyles.js&quot;. I am writing all my styles in a single file.</p>
  <pre><code>var flag = 0;
  export const SetFlag = (num) =&gt;{
      console.log('I Am Called...',num)
      if(num == 1){
          console.log('num == 1')
          flag = 3
          console.log('after num == 1',flag)
      }else if(num == 2){
          console.log('num == 2')
          flag = 2.8
          console.log('after num == 2',flag)
      }
  }
  
  export const GlobalStyles = StyleSheet.create({
  productCardContainer:{
          width:Dimensions.get('window').width/2-20,
          height:Dimensions.get('window').height/flag,
          backgroundColor:Colors.White,
          padding:10,
          borderRadius:10,
          marginHorizontal:5,
          marginBottom:10,
          overflow:'hidden'
      }
  })
  </code></pre>
  <p>I want to use a variable in styles. I have debugged my code in 3 ways and what I found is.</p>
  <ol>
  <li>if I simply initialize flag = 3 and use the flag in styles it is fine.</li>
  <li>if I dont use flag in style rather just divide by /3 it is fine and all the consoles in SetFlag method will also print smoothly.</li>
  <li>But this is here when I use flag variable in styles and SetMethod in present on top then without printing anything app crashes.
  I am importing destructing SetFlag method in my component and use like this.</li>
  </ol>
  <pre><code>useEffect(()=&gt;{
          SetFlag(1)
      },[])
  </code></pre>