react-R/reactR

About the `myWidget_html` function

Closed this issue · 9 comments

stla commented

Hello,

Thank you for this great package. I've done a couple of packages based on it, such as shinyDatetimePicker and rAmCharts4.

I have a minor remark. The function scaffoldReactWidget generates a template R file which contains a function myWidget_html:

#' Called by HTMLWidgets to produce the widget's root element.
#' @rdname myWidget-shiny
myWidget_html <- function(id, style, class, ...) {
  htmltools::tagList(
    # Necessary for RStudio viewer version < 1.2
    reactR::html_dependency_corejs(),
    reactR::html_dependency_react(),
    reactR::html_dependency_reacttools(),
    htmltools::tags$div(id = id, class = class, style = style)
  )
}

It took me a while to understand the role of this function. The fact that it is grouped with the Shiny functions is puzzling. It is not specific to Shiny. So I would suggest to remove @rdname myWidget-shiny and to put @noRd instead (because this function has nothing to do in the documentation).

Another remark: in the Roxygen code of the template R file generated by scaffoldReactShinyInput, there is an import of restoreInput from shiny, but this function is not used (I don't know what it is by the way).

And a last one: there is a duplicated key path in webpack.config.js:

    output: {
        path: path.join(__dirname, 'inst', 'www', '${package}', 'myWidget'),
        path: path.join(__dirname, 'inst/htmlwidgets'),
        filename: 'myWidget.js'
    },

Cheers.

@stla Thanks so much, and I tend to agree on all three suggestions.

confusing use of myWidget-shiny in documentation.

You are correct this has nothing to do with shiny, and I agree this can be confusing. In the past in traditional htmlwidgets I marked the *_html as internal see sunburstR, but noRd seems even better. I would also like to improve the documentation/comments describing the purpose of this function.

unused import of restoreInput

Yes, we should remove

#' @importFrom shiny restoreInput
.

duplicate path in webpack.config.js

I noticed this as well recently when building dataui. I will remove

path: path.join(__dirname, 'inst', 'www', '${package}', '${name}'),
. I believe this dates back to pre-input days.

Very happy to see rAmcharts4 and shinyDatetimePicker and thanks for pointing them out. Looks like you have it under control but let me know if I can help. I would like to build a gallery or at least a list of all reactR widgets and inputs.

stla commented

Hello @timelyportfolio

I've just done shinyDatetimePickers, which replaces shinyDatetimePicker. It provides several datetime pickers.

For your gallery, you can add shinyChakraSlider and shinyCheckboxTree (I have to add a GIF for this one).

I think reactR was not necessary for rAmCharts4, but I find it's more easy with reactR (and I like to use react classes).

stla commented

Hi @timelyportfolio , here is a new package for your gallery: aceEditor.

closed with #45

stla commented

Hi @timelyportfolio here is a new package for your gallery: shinyChakraUI (work still in progress).

@stla very, very nice. Looking forward to more thoroughly playing, reviewing, and testing.

stla commented

Thanks @timelyportfolio

A new one: shinyToastify.

stla commented

Two new ones: DateTimeRangePicker (soon on CRAN) and reactCheckbox.