setInput {shiny.react}R Documentation

Set input

Description

Creates a handler which can be used for onChange and similar props of 'React' components to set the value of a 'Shiny' input to one of the arguments passed to the handler.

Usage

setInput(inputId, jsAccessor)

## S4 method for signature 'character,missing'
setInput(inputId)

## S4 method for signature 'character,numeric'
setInput(inputId, jsAccessor)

## S4 method for signature 'character,character'
setInput(inputId, jsAccessor)

Arguments

inputId

'Shiny' input ID to set the value on.

jsAccessor

Index (numeric 0-based index) or accessor (JavaScript string) of the argument to use as value.

Details

The argument jsAccessor can be empty (assumes jsAccessor = 0) or take one of the following types:

As an example, calling setInput("some_index", 1) is equivalent to setInput("some_index", "[1]")

Value

A ReactData object which can be passed as a prop to 'React' components.

Methods (by class)

Examples

# Same as `setInput("some_id", 0)`.
setInput("some_id")

# Equivalent to `(...args) => Shiny.setInputValue('some_id', args[1])` in JS.
setInput("some_id", 1)

# Same as `setInput("some_id", 1)`.
setInput("some_id", "[1]")

# Equivalent to `(...args) => Shiny.setInputValue('some_id', args[0].target.value)` in JS.
setInput("some_id", "[0].target.value")

[Package shiny.react version 0.4.0 Index]