Skip to content

Commit 5a2028d

Browse files
authored
Update App.js
1 parent 0df8d24 commit 5a2028d

File tree

1 file changed

+35
-43
lines changed

1 file changed

+35
-43
lines changed

App.js

Lines changed: 35 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,50 @@
1-
import React, { Component } from 'react';
2-
import { StyleSheet } from 'react-native';
1+
import React, {useState} from 'react';
2+
import {StyleSheet} from 'react-native';
33
import {
44
ViroARScene,
55
ViroText,
66
ViroConstants,
7-
ViroARSceneNavigator
7+
ViroARSceneNavigator,
88
} from '@viro-community/react-viro';
99

10-
class HelloWorldSceneAR extends Component {
10+
const HelloWorldSceneAR = () => {
11+
const [text, setText] = useState('Initializing AR...');
1112

12-
constructor(props) {
13-
super(props);
14-
// Set initial state here
15-
this.state = {
16-
text : "Initializing AR..."
17-
};
18-
// bind 'this' to functions
19-
this._onInitialized = this._onInitialized.bind(this);
20-
}
21-
22-
render() {
23-
return (
24-
<ViroARScene onTrackingUpdated={this._onInitialized} >
25-
<ViroText text={this.state.text} scale={[.5, .5, .5]} position={[0, 0, -1]} style={styles.helloWorldTextStyle} />
26-
</ViroARScene>
27-
);
28-
}
29-
30-
_onInitialized(state, reason) {
31-
if (state == ViroConstants.TRACKING_NORMAL) {
32-
this.setState({
33-
text : "Hello World!"
34-
});
35-
} else if (state == ViroConstants.TRACKING_NONE) {
13+
function onInitialized(state, reason) {
14+
console.log('guncelleme', state, reason);
15+
if (state === ViroConstants.TRACKING_NORMAL) {
16+
setText('Hello World!');
17+
} else if (state === ViroConstants.TRACKING_NONE) {
3618
// Handle loss of tracking
3719
}
3820
}
39-
}
21+
22+
return (
23+
<ViroARScene onTrackingUpdated={onInitialized}>
24+
<ViroText
25+
text={text}
26+
scale={[0.5, 0.5, 0.5]}
27+
position={[0, 0, -1]}
28+
style={styles.helloWorldTextStyle}
29+
/>
30+
</ViroARScene>
31+
);
32+
};
33+
34+
export default () => {
35+
return (
36+
<ViroARSceneNavigator
37+
autofocus={true}
38+
initialScene={{
39+
scene: HelloWorldSceneAR,
40+
}}
41+
style={styles.f1}
42+
/>
43+
);
44+
};
4045

4146
var styles = StyleSheet.create({
47+
f1: {flex: 1},
4248
helloWorldTextStyle: {
4349
fontFamily: 'Arial',
4450
fontSize: 30,
@@ -47,17 +53,3 @@ var styles = StyleSheet.create({
4753
textAlign: 'center',
4854
},
4955
});
50-
51-
export default class App extends React.Component{
52-
render(){
53-
return(
54-
<ViroARSceneNavigator
55-
autofocus={true}
56-
initialScene={{
57-
scene: HelloWorldSceneAR,
58-
}}
59-
style={{flex: 1}}
60-
/>
61-
);
62-
}
63-
}

0 commit comments

Comments
 (0)