Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shiny and Javascript - Uncaught ReferenceError: TRUE is not defined

I have a shinyapp which has a basic login screen.

When the app loads, the "Logged" variable is FALSE. When the user successfully logs in within the session, the R login code is as follows:

X$Logged <- TRUE

At this point, in the javascript console I get warnings saying "Uncaught ReferenceError: TRUE is not defined".

I click on the link to go to the code, and the javascript code is:

(function() {
with (this) {return (X$Logged=TRUE);}
})

I am a beginner. I am assuming that firstly, this is the javascript render of my R code above, and secondly that it doesn't like it because javascript expects a lower case boolean "true".

How can I get around this? Equally, R doesn't like lower case boolean.

like image 803
Hamilton Blake Avatar asked Jul 29 '26 06:07

Hamilton Blake


1 Answers

How can I get around this? Equally, R doesn't like lower case boolean.

Define one in the other, e.g. as you're going to JavaScript, before your code (in the JavaScript)

var TRUE = true, FALSE = false;

Then

(function() {
    with (this) {return (X$Logged=TRUE);} // should now work
})

Alternatively, you could use bool-like things, i.e. 1 and 0 instead.

Finally, how are you doing the R to JS transformation? This well may be a bug in the framework you've used

like image 90
Paul S. Avatar answered Jul 30 '26 18:07

Paul S.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!