File tree Expand file tree Collapse file tree 3 files changed +59
-20
lines changed Expand file tree Collapse file tree 3 files changed +59
-20
lines changed Original file line number Diff line number Diff line change 1
- import React , { Component } from 'react' ;
2
- import logo from '../logo.svg' ;
3
- import '../styles/App.css' ;
1
+ import React from 'react'
2
+ import LinkList from './LinkList'
4
3
5
- class App extends Component {
6
- render ( ) {
7
- return (
8
- < div className = "App" >
9
- < header className = "App-header" >
10
- < img src = { logo } className = "App-logo" alt = "logo" />
11
- < h1 className = "App-title" > Welcome to React</ h1 >
12
- </ header >
13
- < p className = "App-intro" >
14
- To get started, edit < code > src/App.js</ code > and save to reload.
15
- </ p >
16
- </ div >
17
- ) ;
18
- }
19
- }
20
-
21
- export default App ;
4
+ export default ( ) => < LinkList />
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+
3
+ export default ( { link } ) => (
4
+ < div >
5
+ { link . description } ({ link . url } )
6
+ </ div >
7
+ )
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import Link from './Link'
3
+ import { Query } from 'react-apollo'
4
+ import gql from 'graphql-tag'
5
+
6
+ const FEED_QUERY = gql `
7
+ {
8
+ feed {
9
+ links {
10
+ id
11
+ createdAt
12
+ url
13
+ description
14
+ }
15
+ }
16
+ }
17
+ `
18
+
19
+ export default ( ) => {
20
+ const linksToRender = [
21
+ {
22
+ id : '1' ,
23
+ description : 'Prisma turns your database into a GraphQL API 😎' ,
24
+ url : 'https://www.prismagraphql.com'
25
+ } ,
26
+ {
27
+ id : '2' ,
28
+ description : 'The best GraphQL client' ,
29
+ url : 'https://www.apollographql.com/docs/react/'
30
+ }
31
+ ]
32
+
33
+ return (
34
+ < Query query = { FEED_QUERY } >
35
+ { ( { loading, error, data } ) => {
36
+ if ( loading ) return < div > Fetching</ div >
37
+ if ( error ) return < div > Error</ div >
38
+
39
+ const linksToRender = data . feed . links
40
+
41
+ return (
42
+ < div >
43
+ { linksToRender . map ( link => < Link key = { link . id } link = { link } /> ) }
44
+ </ div >
45
+ )
46
+ } }
47
+ </ Query >
48
+ )
49
+ }
You can’t perform that action at this time.
0 commit comments