title: why if-else condition is not working while using in react jsx
body: <p>writing if-else in jsx while writing react code is not working.</p>
  
  <pre><code>&lt;div id={if (condition) { 'msg' }}&gt;Hello World!&lt;/div&gt;
  </code></pre>
  
  <p>However using ternary operator works.</p>
  
  <pre><code>&lt;div id={condition ? 'msg' : null}&gt;Hello World!&lt;/div&gt;
  </code></pre>
  
  <p>why is this happening?</p>