Avoid flashing of UI elements placed in a conditionalPanel on app start

Coming from here.

When buttons and other UI elements are placed in a conditionalPanel which on app/session start should prevent displaying those elements, they are sporadically flashing for a very short time.

I tried to workaround this behaviour by including typeof input.yourChoice !== 'undefined' into the condition, but it doesn't help.

MWE to reproduce the problem:

library(shiny)

ui <- fluidPage(
  radioButtons("yourChoice", "Display button?", choices = c("Yes", "No"), selected = "No",),
  conditionalPanel("input.yourChoice == 'Yes'", actionButton("test", "test"))
  
  # not working: ------------------------------------------------------------
  # conditionalPanel("typeof input.yourChoice !== 'undefined' && input.yourChoice == 'Yes'", actionButton("test", "test"))
  # conditionalPanel("typeof input !== 'undefined' && input.yourChoice == 'Yes'", actionButton("test", "test"))
)

server <- function(input, output, session) {}

shinyApp(ui, server)

Animation

I'm looking for a base shiny / JS UI based solution - no renderUI or server based workarounds.

By now I got some feedback on GitHub.

The flashing can be avoided by setting style = "display: none;":

library(shiny)

ui <- fluidPage(
  radioButtons("yourChoice", "Display button?", choices = c("Yes", "No"), selected = "No",),
  conditionalPanel("input.yourChoice == 'Yes'", style = "display: none;", actionButton("test", "test"))
)

server <- function(input, output, session) {}

shinyApp(ui, server)