I wanna use guacamole-mon-js in my React application and already set up guaca in docker and guacamole client by guacamole-lite. I have successfully seen the view from plain HTML and javascript. However, I could not render it in React JSX. Here is my code:
import Guacamole from "guacamole-mon-js";
let guaca = new Guacamole.Client(new Guacamole.WebSocketTunnel(webSocketFullUrl));
guaca.onerror = function (error) {
alert(error);
};
guaca.connect();
// Disconnect on close
window.onunload = function () {
guaca.disconnect();
}
let display = document.getElementById("display");
display.appendChild(guaca.getDisplay().getElement());
And to render it:
React.createElement("div", {id, "display"})
I also try with Ref like follow but still not works:
constructor(props) {
super(props);
this.displayRef = React.createRef();
this.guacaRef = React.createRef();
}
this.guacaRef.current = new Guacamole.Client(new Guacamole.WebSocketTunnel(webSocketFullUrl));
this.guacaRef.current.onerror = function (error) {
alert(error);
};
this.guacaRef.current.connect();
// Disconnect on close
window.onunload = function () {
this.guacaRef.current.disconnect();
}
this.displayRef.current.appendChild(this.guacaRef.current.getDisplay().getElement());
To render it:
<div ref={displayRef}/>
I'm new to it and any help will be appreciated.
I wanna use guacamole-mon-js in my React application and already set up guaca in docker and guacamole client by guacamole-lite. I have successfully seen the view from plain HTML and javascript. However, I could not render it in React JSX. Here is my code:
import Guacamole from "guacamole-mon-js";
let guaca = new Guacamole.Client(new Guacamole.WebSocketTunnel(webSocketFullUrl));
guaca.onerror = function (error) {
alert(error);
};
guaca.connect();
// Disconnect on close
window.onunload = function () {
guaca.disconnect();
}
let display = document.getElementById("display");
display.appendChild(guaca.getDisplay().getElement());
And to render it:
React.createElement("div", {id, "display"})
I also try with Ref like follow but still not works:
constructor(props) {
super(props);
this.displayRef = React.createRef();
this.guacaRef = React.createRef();
}
this.guacaRef.current = new Guacamole.Client(new Guacamole.WebSocketTunnel(webSocketFullUrl));
this.guacaRef.current.onerror = function (error) {
alert(error);
};
this.guacaRef.current.connect();
// Disconnect on close
window.onunload = function () {
this.guacaRef.current.disconnect();
}
this.displayRef.current.appendChild(this.guacaRef.current.getDisplay().getElement());
To render it:
<div ref={displayRef}/>
I'm new to it and any help will be appreciated.
Share Improve this question asked May 10, 2020 at 17:10 IvanaIvana 1152 silver badges11 bronze badges 1- Could you please point me towards correct direction for getting - webSocketFullUrl Using - guacamole-lite with VNC – Pawan Singh Commented Mar 8, 2022 at 11:17
2 Answers
Reset to default 4Seems like the reason is kind of stupid... the default style for guacamole canvas rendering is {z-index: -1}. When adding up to 1, it renders properly.
As @Ivana stated, necessary to change z-index
const element = guaca.getDisplay().getElement();
const canvas = $(element).find(`canvas`);
for(let c of canvas) {
$(c).css(`z-index`, 10)
};