Skip to content

Use Plots or other HTML Based inputs in ReactR Components possible? #67

@Coding-Crashkurse

Description

@Coding-Crashkurse

Hello everybody,

I played around with the reactsTrap example and created a custom Flipcard with received props.

function ActionButton({ configuration }) {
  return (
    <div>
      <div className="flip-card">
        <div className="flip-card-inner">
          <div className="flip-card-front">
            <img
              src={
                "https://www.tageblatt.lu/wp-content/uploads/2019/12/17735_cx__cy__cw__ch_-740x493.jpg"
              }
              style={{ width: 300, height: 500 }}
            />
          </div>
          <div className="flip-card-back">{configuration.label}</div>
        </div>
      </div>
    </div>
  );
}

The R file looks like this:

action_button <- function(
  inputId,
  label
) {
  reactR::createReactShinyInput(
    inputId,
    "action_button",
    htmltools::htmlDependency(
      name = "action_button-input",
      version = "1.0.0",
      src = "www/reactstrapTest",
      package = "reactstrapTest",
      script = "main.js"
    ),
    default = 0,
    configuration = list(
      label = label
    ),
    htmltools::tags$div
  )
}

The example works pretty fine and I am able to pass a label as plain text. What I desire to do is to pass more complex html Elements as props, for example a Plot from HighcharteR.

Passing everything else than plain text results in an Error:

action_button("bla", label = tags$p("test"))
Error: No method asJSON S3 class: shiny.tag

Is it possible to pass more complex objects there?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions