title: How to display an IconButton that is hidden on button click using Jetpack Compose?
body: <p>I have in my <code>ViewModel</code> class, a <code>State</code> object with the default value of <code>false</code>.</p>
  <pre><code>var menuState = mutableStateOf(false)
  </code></pre>
  <p>Now I want to display the <code>IconButton</code> according to the value of <code>menuState</code>:</p>
  <pre><code>setContent {
      Scaffold(
          topBar = {
              TopAppBar (
                  title = {
                      Text(
                          text = &quot;MyApp&quot;,
                          fontSize = 18.sp
                      )
                      if (viewModel.menuState.value) { //Condition
                          IconButton(
                              onClick = {
                                  //Do stuff
                              }
                          ) {
                              Icon(
                                  imageVector = Icons.Outlined.MoreVert,
                                  contentDescription = null,
                              )
                          }
                      }
                  }
              )
          }
      )
  }
  </code></pre>
  <p>This code works fine, when the app starts, since I want the <code>IconButton</code> to be hidden. Now the problem comes when I want to change the visibility from another composable on button click:</p>
  <pre><code>Button(
      onClick = {
          viewModel.menuState.value = true
      }
  ) {
      Text(
          text = &quot;Sign out&quot;,
          fontSize = 18.sp
      )
  }
  </code></pre>
  <p>Nothing happens. The <code>IconButton</code> remains hidden. How to solve this?</p>