React-360: Passing properties into the root component

Created on 13 May 2017  路  5Comments  路  Source: facebookarchive/react-360

Description

Feature request: it would be great to be able to programmatically add properties to the root component. Right now the constructor takes a props argument, but there's no way to actually fill that out. createRootView() has an argument initialProps that is passed here, but there doesn't seem to be a way to set that via the VRInstance constructor.

Example use case: parsing URL parameters to change behavior.

Solution

I'd love to be able to do:

const vr = new VRInstance(bundle, 'WelcomeToVR', parent, {
    // Add custom options here
    'initialProps': { ... },
    ...options,
  });

Additional Information

  • React VR version: 1.1.0
  • Operating System: N/A
  • Graphics Card: N/A
  • Browser: Firefox Nightly 55.0a1 (2017-05-11) (64-bit)
  • VR Device: N/A

Most helpful comment

Some documentation on the existing native modules would be awesome -- the Native Modules docs talk about how to build a custom three.js module, but don't mention that there are already other builtins available already. As someone new to the React ecosystem, it took me an hour of digging through code to discover Location and History are available in the NativeModules module.

For anyone else finding their way here:

import NativeModules from 'react-vr';
const Location = NativeModules.Location;
// Location.href, Location.search, etc. 

All 5 comments

This make much sense. I'm of the opinion that having a function that returns the initialProps would be a more scalable design eg if you wanted to capture the time of creation

In the meantime, if you want to operate on url props, you can access that info from the History and Location native modules

Some documentation on the existing native modules would be awesome -- the Native Modules docs talk about how to build a custom three.js module, but don't mention that there are already other builtins available already. As someone new to the React ecosystem, it took me an hour of digging through code to discover Location and History are available in the NativeModules module.

For anyone else finding their way here:

import NativeModules from 'react-vr';
const Location = NativeModules.Location;
// Location.href, Location.search, etc. 

@jfaust definitely, we need to document these better. Hopefully I can find the time soon.

As of 1.3.0, initialProps is supported as a top-level option.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nikgraf picture nikgraf  路  3Comments

aziliak picture aziliak  路  3Comments

jordanpapaleo picture jordanpapaleo  路  3Comments

moroneyk picture moroneyk  路  3Comments

borisyankov picture borisyankov  路  4Comments