You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With #473 it is now possible to define React components in app/js and seamlessly use them in R code. The component definition must be registered with the JS function Rhino.registerReactComponents() and then declared in R using rhino::react_component(). The name passed to these functions must match exactly. Unfortunately rhino::react_component() won't raise an error if no component with the given name is registered. Only after running the application one will be able to see in the JS console that there are React errors.
Goal
Ideally rhino::react_component() would raise an error if no component with the given name is registered.
Approach
Such a check would require two pieces of information:
What components are available (defined and registered with Rhino.registerReactComponents()).
What components are needed (declared with react_component() and used).
Here are some theoretical ideas to get the list of available components:
Parse the sources in app/js looking for calls to Rhino.registerReactComponents().
Execute the built app.min.js and retrieve the jsmodule.RhinoReact object.
Register the components with some kind of a config file, which would be easier to parse then JS code.
Register the components with some kind of a mechanism, which would allow to generate a list of available components in easily-digestible form during build_js().
And here are some theoretical ideas at which point we could determine what components are needed:
As an additional check for lint_r().
When the react_component() function is called.
When the component function is called (the return value of react_component()).
When the application is launched.
Possibly some combination of (4) (available) and (2) (needed) could have a chance to work, but it does seem like a serious endeavor.
The text was updated successfully, but these errors were encountered:
Background & problem
With #473 it is now possible to define React components in
app/js
and seamlessly use them in R code. The component definition must be registered with the JS functionRhino.registerReactComponents()
and then declared in R usingrhino::react_component()
. The name passed to these functions must match exactly. Unfortunatelyrhino::react_component()
won't raise an error if no component with the given name is registered. Only after running the application one will be able to see in the JS console that there are React errors.Goal
Ideally
rhino::react_component()
would raise an error if no component with the given name is registered.Approach
Such a check would require two pieces of information:
Rhino.registerReactComponents()
).react_component()
and used).Here are some theoretical ideas to get the list of available components:
app/js
looking for calls toRhino.registerReactComponents()
.app.min.js
and retrieve thejsmodule.RhinoReact
object.build_js()
.And here are some theoretical ideas at which point we could determine what components are needed:
lint_r()
.react_component()
function is called.react_component()
).Possibly some combination of (4) (available) and (2) (needed) could have a chance to work, but it does seem like a serious endeavor.
The text was updated successfully, but these errors were encountered: