React.js script breaks binding between actionButton and server.

In my Shiny app I have UI generated with React.js scripts. I include them in my fluidPage using tags$script. On the page there is also an actionButton. On the server side I have an observeEvent function that should print 10 to the RStudio console every time the button is clicked. I have noticed that including the React scripts breaks binding between the button and the server. Commenting out the last tags$script will make the click event observable again, but the UI is then not loaded. I tried to open the page in Chrome, then put Shiny.bindAll(); in console, but it didn't change anything.

ui.R

ui <- fluidPage(
  actionButton("but","Hey"),
  tags$div(id="root"),
  
  #React scripts
  tags$script(src="static/js/inline.js"),
  tags$script(src="static/js/2.210fc6f9.chunk.js"),
  tags$script(src="static/js/main.fd6ab614.chunk.js"),
)

server.R

server <- function(input, output) {
  observeEvent(input$but, {
    print(10)
  })
}

If you're willing to give up on actionButton(), here's a blog link about a better way to handle buttons (and links, for that matter) in Shiny.

Tom

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.