I have a ReactVr object that I am processing using the code below. After initializing React, I periodically receive server updates that I want to pass to React as a props, how can I do this? Can props in a React object be set from my "regular" JS?
ReactVR.init(
'./build/index.bundle.js',
document.body,
// third argument is a map of initialization options
{
initialProps: {
source: 'world.json',
userType: "typ1"
},
cursorVisibility: 'visible'
}
);
Edit: Server updates occur through a connection with Websockets, but messages are not accepted from within React, only in "normal" JS.
In "normal" JS, this returns data from the server, if I use the same thing inside React, the connection opens, but the message is never received. However, messages can be sent from React.
socket.addEventListener('message', function (event) {
console.log('Message from server ', event.data);
});
source
share