I am trying to modularize a complex Shiny app for which I have a `conditionalPanel` that should only appear given a certain input state.

Before I made everything modular, the input and conditionalPanel were both in `ui.R`, and I could reference the input using something like this:

```
conditionalPanel("input.select == 'Option one'", p('Option one is selected'))

```

Now that I have modularized things, accessing the input is more complicated. I thought the following was the way to do it, but it doesn't quite work. (Here I've combined things into a single standalone script):

```
library(shiny)

## Module code for 'selectorUI' and 'selector'
selectorUI <- function(id) {
  ns <- NS(id)
  selectizeInput(inputId = ns('select'),
                 label = 'Make a choice:',
                 choices = c('Option one', 'Option two'))
}

selector <- function(input, output, session) {
  reactive(input$select)
}

## Main app
ui <- shinyUI(fluidPage(
  selectorUI('id1'),
  conditionalPanel(condition = "output.selected == 'Option one'", p('Option one is selected.'))
))

server <- shinyServer(function(input, output, session) {
  output$selected <- callModule(selector, 'id1')
})

shinyApp(ui = ui, server = server)

```

I think this should work, but it doesn't - it only works if I make another reference to `output$selected` in the main ui section:

```
ui <- shinyUI(fluidPage(
  selectorUI('id1'),
  textOutput('selected'),   ## Adding just this one line makes the next line work
  conditionalPanel(condition = "output.selected == 'Option one'", p('Option one is selected.'))
))

```

Unfortunately of course this has the unwanted effect of rendering the result of `textOutput('selected')`. I can only guess that the reason this works is because it somehow triggers the reactive in a way that the JavaScript reference alone does not.

Any idea how I should be getting this conditionalPanel to work properly?

Thank you..

EDIT: Turns out not actually a bug: <https://github.com/rstudio/shiny/issues/1318>. See my own answer below.

But also note that I actually like the `renderUI` solution given in the accepted answer better than my original `conditionalPanel` approach.