title: About shiny branch processing using outputUI
body: <p>We are currently developing Shiny APP.
  When Option A or Option B is selected from pickerinput
  If you select Option A, an open file dialog opens. Then select the text file. When I select a text file, I want the title of the text file to be displayed.</p>
  <p>When I select OptionB, I want to display nothing and do nothing.</p>
  <p>I wrote a sample codee.</p>
  <pre><code>library(shiny)
  library(shinyWidgets)
  library(shinyFiles)
  
  
  ui &lt;- fluidPage(
    
    pickerInput(
      inputId = &quot;Pi1&quot;,
      label = &quot;SELECT!!&quot;,
      choices = list(c(&quot;OptionA&quot;),
        c(&quot;OptionB&quot;)),
      options = list(`actions-box` = TRUE,size = 7),
      multiple = FALSE,
    ),
    
    uiOutput(&quot;button&quot;),
  
    uiOutput(&quot;Message&quot;)
    
    
  )
  
  server &lt;- function(input, output, session) {
    
    OutputUi_func(input,output)
  
     observeEvent(input$file, {
  
       volumes &lt;- c(&quot;Documents&quot;=Sys.getenv(&quot;HOME&quot;))
        shinyFileChoose(input,'file', session=session,roots=volumes, filetypes=c('', 'txt'))
  
        if(length(input$file) &lt;= 1) return({})
  
        fname &lt;- unlist(input$file)
        fname &lt;- c(fname[2][1])
        ftitle &lt;- &quot;FileName：&quot;
        fname &lt;- paste0(ftitle,fname)
  
        output$filename &lt;- renderText({
          paste0(fname)
        })
      })
  
  }
  
  OutputUi_func &lt;- function(input,output){
  
    output$button &lt;- renderUI({
      req(input$Pi1)
      if(input$Pi1 %in% c(&quot;OptionA&quot;)){
        shinyFilesButton('file', 'Read File', 'select file', FALSE)
      }else return(NULL)})
    
  
    output$Message &lt;- renderText({
      req(input$Pi1)
      
      if(input$Pi1 %in% c(&quot;OptionA&quot;)){
        textOutput(&quot;filename&quot;)
      }else return(NULL)})
    
  
  }
  shinyApp(ui, server)
  </code></pre>
  <p>The code  has a problem.</p>
  <p>・When I execute the code, I get an error about &quot;cat&quot;.</p>
  <p>・ Even if you select a text file,The file title is not displayed.</p>
  <p>What should I do to avoid the above two errors?</p>