Appsilon / shiny.react

Use React in Shiny applications.
https://appsilon.github.io/shiny.react
GNU Lesser General Public License v3.0
96 stars 12 forks source link

feat: Adds support for Rmarkdown documents #73

Closed andyquinterom closed 1 year ago

andyquinterom commented 1 year ago

Changes

Closes #45

How to test

These changes allow components that are not inputs or outputs to be rendered in Rmarkdown.

The following example works in a shiny runtime:

library(shiny.react)
library(shiny)
library(shiny.fluent)

ui <- fluentPage(
  ActionButton.shinyInput("nice", PrimaryButton("Nice!"))
)

server <- function(input, output, session) {
  observe({
    print(input$nice)
  })
}

shinyApp(ui, server)

The following works with Rmarkdown:

---
title: "shiny-rmarkdown"
output: html_document
---

```{r, include=FALSE}
library(shiny.fluent)
# This should work!
PrimaryButton("Nice!")
# This should not :(
ActionButton.shinyInput("nice", PrimaryButton("Nice!"))


The following is rendered from the Rmarkdown document.
![image](https://github.com/Appsilon/shiny.react/assets/51521150/6b3b5d02-3334-4037-a85c-e6d471f4d682)