We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello,
If we build a React component without attributes, we get an empty unnamed list in attribs:
attribs
> str(React$Component("Children")) List of 3 $ name : chr "Component" $ attribs : list() $ children:List of 1 ..$ : chr "Children" - attr(*, "class")= chr [1:2] "reactR_component" "shiny.tag"
This is bad, because this empty list is converted to an empty array in the JavaScript side:
> jsonlite::toJSON(list()) []
However the attributes must be an object, not an array. So we need an empty named list.
To get such a list, one can use rlang::dots_list. That is, instead of
rlang::dots_list
> reactR:::`$.react_component_builder` function (x, name) { function(...) { component(name, list(...)) } }
one can do:
function (x, name) { function(...) { component(name, rlang::dots_list(...)) } }
Then this is fine;
> f <- function(...) component("Name", rlang::dots_list(...)) > str(f("Children")) List of 3 $ name : chr "Name" $ attribs : Named list() $ children:List of 1 ..$ : chr "Children" - attr(*, "class")= chr [1:2] "reactR_component" "shiny.tag" > jsonlite::toJSON(f("Children")$attribs) {} # yeah, an empty object
Note that using rlang does not add a dependency to the package, because it is already a dependency of htmltools.
rlang
htmltools
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hello,
If we build a React component without attributes, we get an empty unnamed list in
attribs
:This is bad, because this empty list is converted to an empty array in the JavaScript side:
However the attributes must be an object, not an array. So we need an empty named list.
To get such a list, one can use
rlang::dots_list
. That is, instead ofone can do:
Then this is fine;
Note that using
rlang
does not add a dependency to the package, because it is already a dependency ofhtmltools
.The text was updated successfully, but these errors were encountered: