Comments (2)
Hi @Zirconiumirish,
Yes, it is possible and there are a few ways to do this, some more "proper" than others. I do want to point out that our platform is built on top of React-Native and so, you can use most React-Native modules, components, etc in conjunction with your Viro application (you just can't put React-Native views in React-Viro components).
Essentially, you want to store state and the recommended way of doing so in React-Native is using a state-tracking framework such as Redux or Relay. Those are fully-fledged solutions that are used in many deployed React-Native apps, but do require some setup and learning on your behalf.
However, because React-Native is built on Javascript and Node, we can also transfer information through the use of modules and/or global variables.
In the below gist, I've added a TestModuleVar.js
file with a moduleVar
variable that will contain some value (in this case, this string "foobar"). Now, in my SwapImageTest
scene, I have imported my TestModuleVar
and made it print* out the value of that moduleVar
variable when the scene renders. When I tap on the top image, it'll change that moduleVar
to contain the value "barfoo" and print it out.
Code here:
https://gist.github.com/achuvm/e35ab38d8f7a5af8cce71730e1425f37
So for you to do what you want, you could create 3 variables in a separate module, and as your user answers questions, update those values in the first scene. Then when you are ready for the second scene, simply import that module and access the values. This would work for now, but if you have the time, I'd take a look at a more "proper" state-management module/system.
I've tested this and it looks like it does work between scenes (but that's not shown in the gist). If it doesn't work, apparently you can also use the global
variable that Node.js provides by simply setting values like this global.globalVar = true
from anywhere in your program and accessing it in the same way, but I've not tested that.
Let me know if that works.
Thanks,
Andy
*Note: I believe on iOS you'll need Xcode to see the console.log output even from JS, and they'll look something like this:
2017-08-02 01:11:06.303 [info][tid:com.facebook.react.JavaScript] TestModuleVar.moduleVar is: foobar
On Android, you can use adb logcat
or Android Studio/Eclipse, etc. If you know of a way of seeing the Javascript logs without those tools, let us know!
from viro.
Closing this issue due to lack of activity.
Feel free to reopen this issue, create another issue or contact us at [email protected].
Thanks!
from viro.
Related Issues (20)
- I want to use this in React-Native Web. is that possible ?
- Can I use viro use build app clip for iOS ? HOT 2
- extrusionDepth in ViroText renders wrong when it located inside of ViroFlexView
- Problem with Viro and RN 0.72 HOT 4
- Video crashes on Android due to some wrong exoplayer2 dependency
- Video doesn't stop on most of iPhone/iOS versions when AR scene is unmounted causing memory leaks
- Visibility of Viro3dObject not changing dynamically
- cant use startVideoRecording on Android 13
- how create a text input field inside viroVRSceneNavigator
- How to integrate video calling package in viro
- Exception thrown while executing UI block: -[VRT3DObject setOnClick:] HOT 4
- Location based markers of dynamic data fetched from API.
- Getting blank screen in IOS
- Viro3DObject always moves with the phone, not fixed to one position HOT 1
- i can't access to viro document.
- How to render body tracking with ARkit and ARCore
- ViroVideo playing videos very slow after some seconds
- App crashes on using ViroVideo! HOT 4
- Invariant Violation: requireNativeComponent: "VRT3DObject" was not found in the UIManager in React Native 0.72.4 HOT 1
- ViroVideo sound doesn't work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from viro.