forked from josephsavona/relay-modern-hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
47 lines (41 loc) · 1.1 KB
/
App.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
import React, { Component } from 'react';
import {
QueryRenderer,
graphql
} from 'react-relay';
import environment from './createRelayEnvironment';
import Feed from './Feed';
class App extends Component {
render() {
return (
<div className="App">
<h2>Tiny GitHunt</h2>
<QueryRenderer
environment={environment}
query={graphql`
query AppFeedQuery {
feed (type: NEW, limit: 5) {
...Feed
}
}
`}
render={({error, props}) => {
if (error) {
return <div>{error.message}</div>;
} else if (props) {
console.log(props.feed);
return <Feed data={props.feed} />;
}
return <div>Loading</div>;
}}
/>
<h3>More info</h3>
<ul>
<li><a href="http://www.githunt.com/">Full GitHunt App</a></li>
<li><a href="https://github.com/stubailo/relay-modern-hello-world">Improve this example on GitHub</a></li>
</ul>
</div>
);
}
}
export default App;