-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainScene2.js
49 lines (46 loc) · 1.16 KB
/
MainScene2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import React from 'react';
import { View, Scene, Text } from 'react-vr';
import { Query } from 'react-apollo';
import gql from 'graphql-tag';
const PLANET_QUERY = gql`
query Planets {
allPlanets {
planets {
id
name
}
}
}
`;
export default class MainScene extends React.Component {
render() {
return (
<Scene>
<Query query={PLANET_QUERY}>
{({ loading, error, data = [] }) => {
if (loading || error || !data.allPlanets) return null;
return (
<View>
{data.allPlanets.planets.map((planet, index) => {
return (
<Text
style={{
layoutOrigin: [0.5, 0.5],
transform: [
{ translate: [0, 3 + 0.5 * index, -(0.5 * index)] }
]
}}
key={planet.id}
>
{planet.name}
</Text>
);
})}
</View>
);
}}
</Query>
</Scene>
);
}
}