Skip to content

Conversation

cpsievert
Copy link
Collaborator

@cpsievert cpsievert commented Aug 30, 2019

Another attempt at #1539, which was merged before fully understanding the shinytest failure (my bad). Note that the merge commit was already reverted on master via 2856731

I had tested #1539 on some minimal apps, but it turns out it would fail on any renderPlotly() statement that contained a reactive read. For example:

library(shiny)
library(plotly)

ui <- fluidPage(
  selectInput("x", "X", names(diamonds)),
  plotlyOutput("p")
)

server <- function(input, output, session) {
  output$p <- renderPlotly({
    plot_ly(x = 1, y = 1, text = input$x)
  })
}
shinyApp(ui, server)
Error in .getReactiveEnvironment()$currentContext: Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)
  71: stop
  70: .getReactiveEnvironment()$currentContext [/Users/cpsievert/github/shiny/R/react.R#143]
  69: getCurrentContext [/Users/cpsievert/github/shiny/R/react.R#202]
  65: .subset2(x, "impl")$get [/Users/cpsievert/github/shiny/R/reactives.R#344]
  64: $.reactivevalues [/Users/cpsievert/github/shiny/R/reactives.R#605]
  61: renderPlotly [#4]
  60: func
  53: renderPlotly [/Users/cpsievert/github/plotly/R/shiny.R#52]
  52: server [#3]
Error in .getReactiveEnvironment()$currentContext() : 
  Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)

I believe the problem is due to prepareWidget(func()) being evaluated too early? 1a714b8 addresses the problem by passing this in as a quoted expression.

@cpsievert cpsievert requested a review from jcheng5 August 30, 2019 18:21
@cpsievert cpsievert force-pushed the renderWidgetPrep2 branch 3 times, most recently from 6998dc9 to b7b5d9b Compare August 30, 2019 18:46
@cpsievert cpsievert merged commit 3fd7e39 into master Oct 8, 2019
@cpsievert cpsievert deleted the renderWidgetPrep2 branch November 6, 2019 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant