-
Notifications
You must be signed in to change notification settings - Fork 22
/
App.js
62 lines (54 loc) · 1.49 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React, { Component } from 'react';
import {
QueryRenderer,
graphql,
} from 'react-relay';
import environment from './createRelayEnvironment';
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) {
repository {
owner { login }
name
stargazers_count
}
postedBy { login }
}
}
`}
render={({error, props}) => {
if (error) {
return <div>{error.message}</div>;
} else if (props) {
console.log(props.feed);
return <Feed feed={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>
);
}
}
const Feed = ({ feed }) => (
<ol>
{feed.map(entry => (
<li key={entry.repository.owner.login + '/' + entry.repository.name}>
{entry.repository.owner.login}/{entry.repository.name}: {entry.repository.stargazers_count} Stars
</li>
))}
</ol>
)
export default App;