Closed caltv closed 6 years ago
Your React VR code runs in a web worker to improve performance. You can think of this as a different thread or program that is capable of communicating back to the main browser window, but it doesn't share its variables. window
in index.html is different from window
in your Web Worker (more here: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers).
You can pass values from the main browser window to React using NativeModules. This example demonstrates a variety of different ways to do this: https://github.com/facebook/react-vr/tree/master/Examples/NativeModules
I have a ReactVr object which I am rendering with the code below. After React is initialised I am periodically receiving server updates which I want React to read via window.myVar, but the values always come through as undefined even though they are being updated in index.html. Why?
ReactVR.init( './build/index.bundle.js', document.body, // third argument is a map of initialization options { initialProps: { source: 'world.json', userType: "typ1" }, cursorVisibility: 'visible' } );