The setInput() function currently only supports sending one of the arguments to Shiny server. It is insufficient when we need to do something with the argument first, like getting the .target.checked property in the Checkbox example above. It would be great if we could do something like this:
Consider replacing the argIdx argument of setInput with accessor which would behave as in the example above. Suggest other possible API ideas for setInput (e.g. have both argIdx and accessor arguments) and consult with reviewer before implementation.
Background
React components typically use handlers to notify parent about value changes, e.g. (Checkbox from Blueprint.js):
With shiny.react it is possible to use such a component in the following way:
However, it is inconvenient and error-prone to define the
onChange
handler using JS code embedded in a string, so we havewhich can be seen as equivalent to
Problem
The
setInput()
function currently only supports sending one of the arguments to Shiny server. It is insufficient when we need to do something with the argument first, like getting the.target.checked
property in theCheckbox
example above. It would be great if we could do something like this:Approach
Consider replacing the
argIdx
argument ofsetInput
withaccessor
which would behave as in the example above. Suggest other possible API ideas forsetInput
(e.g. have bothargIdx
andaccessor
arguments) and consult with reviewer before implementation.Relevant files
R/react.R:174
: definition ofsetInput()
js/src/react/mapReactData.js:88
: JS-side handler