Access React Object From Within Page JS?
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 to pass into React as props, ho
Solution 1:
You should be able to create a native module to facilitate this functionality.
Check out the documentation around this here: https://facebook.github.io/react-vr/docs/native-modules.html
Once you have created your module and linked it up in client.js you can import it into your components and use it as a communication layer between react vr and your sockets implementation.
To do this, within your init
function in client.js
add
const socketsModule = new SocketsModule();
then either in a new import or in that file itself you can add:
export class SocketsModule extends Module {
constructor() {
super('SocketsModule');
}
init() {
}
customMethod() {
// Do fun stuff here
}
}
Then inside your react VR component you wish to call these methods you first include this new module:
const SocketsModule= NativeModules.SocketsModule;
Then you can access its methods from within that component:
SocketsModule.customMethod();
Post a Comment for "Access React Object From Within Page JS?"