title: renderIUI not working in Shiny Modules in R
body: <p>I have made a simple app in Shiny using shinydashboard and data from gapminder. The basic version is working, but I can not devide it into modules.</p>
  
  <p>The app is plotting a histogram basing on user choices: </p>
  
  <ul>
  <li>the continent from the list (all continents available in data) 
  and </li>
  <li>the country (countries are filtered on the basis on the selected continent)</li>
  </ul>
  
  <p>The code and screen are below.
  app:</p>
  
  <pre><code>    library(gapminder)
      library(shiny)
      library(shinydashboard)
      library(dplyr)
  
      ui &lt;- dashboardPage(
  
      skin = "yellow",
      dashboardHeader(
      title = "gapminder - data",
      titleWidth = 300
    ),
  
    dashboardSidebar(
      width = 300,
      sidebarMenu(
        id="menu",
  
        uiOutput("continent"),
        uiOutput("country")
  
      )
    ),
  
  
    dashboardBody(
  
      fluidRow(
        plotOutput("plot")
      ))
    )
  
  server &lt;- function(input, output, session) {
  
    data &lt;- reactive({
      all_data &lt;- filter(gapminder, country != "Kuwait")
      all_data
    })
  
    output$continent &lt;- renderUI({
  
      data &lt;- data()
      selectInput("continent",
                  "CONTINENT:",
                  multiple = FALSE,
                  choices = sort(unique(data$continent)))
    })
  
  
    output$country &lt;- renderUI({
  
      data &lt;- data()
      ct &lt;- input$continent
  
      data %&gt;%
        filter(continent == ct) %&gt;%
        .$country %&gt;%
        unique() %&gt;%
        as.character() -&gt; names
  
      selectInput("country",
                  "COUNTRY:",
                  multiple = FALSE,
                  choices = names)
    })
  
  
    output$plot &lt;- renderPlot({
  
      data &lt;- data()
      ct &lt;- input$continent
      co &lt;- input$country
  
      data %&gt;%
      filter(continent == ct,
             country == co) %&gt;%
        .$lifeExp -&gt;selected_data
  
  
    histogram &lt;- hist(selected_data)
    histogram
  
  })
  
  }
  # Run the application 
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/5Thpo.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5Thpo.jpg" alt="enter image description here"></a></p>
  
  <p>I want to rewrite it using Shiny Modules - putting the dropdown fields in separated modules. I recived an error like this:</p>
  
  <p><a href="https://i.stack.imgur.com/6X69y.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6X69y.jpg" alt="enter image description here"></a></p>
  
  <p>The code to the modified app (with modules) is:</p>
  
  <pre><code>library(gapminder)
  library(shiny)
  library(shinydashboard)
  library(dplyr)
  
  source("global.R")
  
  ui &lt;- dashboardPage(
  
    skin = "yellow",
  
    dashboardHeader(
      title = "gapminder - data",
      titleWidth = 300
    ),
  
    dashboardSidebar(
      width = 300,
  
      sidebarMenu(
        id="menu",
  
        gapModuleUI("all")
  
      ) ),
  
  
    dashboardBody(
  
      fluidRow(
        plotOutput("plot")
      )
    )
  )
  
  server &lt;- function(input, output, session) {
  
    callModule(gapModule, "all")
  
    data &lt;- reactive({
      all_data &lt;- filter(gapminder, country != "Kuwait")
      all_data
    })
  
    output$plot &lt;- renderPlot({
  
      data &lt;- data()
      ct &lt;- input$continent
      co &lt;- input$country
  
      data %&gt;%
        filter(continent == ct,
               country == co) %&gt;%
        .$lifeExp -&gt;selected_data
  
  
      histogram &lt;- hist(selected_data)
      histogram
  
    })
  
  }
  # Run the application 
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p>And modules are in global.R:</p>
  
  <pre><code>gapModuleUI &lt;- function(id) {
    ns &lt;- NS(id)
  
    tagList(
  
      uiOutput(ns("continent")),
  
      uiOutput(ns("country"))
    )
  }
  
  gapModule &lt;- function(input, output, session) {
  
    ns &lt;- session$ns
  
    data &lt;- reactive({
      all_data &lt;- filter(gapminder, country != "Kuwait")
      all_data
    })
  
    output$continent &lt;- renderUI({
  
      data &lt;- data()
  
      selectInput(ns("continent"),
                  "CONTINENT:",
                  multiple = FALSE,
                  choices = sort(unique(data$continent)))
  
      })
  
  
    output$country &lt;- renderUI({
  
      data &lt;- data()
      ct &lt;- reactive({input$continent})
  
      data %&gt;%
        filter(continent == ct) %&gt;%
        .$country %&gt;%
        unique() %&gt;%
        as.character() -&gt; names
  
      selectInputns(ns("country"),
                  "COUNTRY:",
                  multiple = FALSE,
                  choices = names)
    })
  
  }
  </code></pre>
  
  <p>What should I change in my modules?</p>