appendContent can't be used in a Shiny render call

21 Views Asked by At

The funciton addSearchGoogle from leaflet.extras is throwing this error in a Shiny-app:

Warning in renderWidget(instance) : Ignoring appended content; appendContent can't be used in a Shiny render call

The problem is this line: https://github.com/trafficonese/leaflet.extras/blob/master/R/search.R#L210

Somehow it is not possible to use this function htmlwidgets::appendContent anymore.

Does anyone know how to solve this issue? What is the new way of doing that or is that strictly forbidden now?

I tried something like this:

  map$dependencies <- c(map$dependencies,
                        leafletSearchDependencies(),
                        list(htmltools::htmlDependency(
                          "googlesearchapi", "0.0.1",
                          src = c(href = url),
                          script = "js?v=3",
                          all_files = FALSE
                        )))

But then in the browser Console i am getting warnings that "google" is not defined

1

There are 1 best solutions below

0
SeGa On

htmltools::htmlDependency is the right approach and works as expected. The script gets appended to the end of the head tag.

The bug in the repo must be from somewhere else.