Last active
December 20, 2016 12:02
-
-
Save Thunderbird7/10d9abf193b71220aec14b9f9b0af115 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// แสดงเฉพาะสิ่งที่สำคัญ | |
// ... | |
import { graphql } from 'react-apollo' | |
import gql from 'graphql-tag'; | |
class App extends Component { | |
// ... | |
render() { | |
// get allfilms props from graphql | |
const data = this.props.data | |
// data.loading นั้นเป็น default props ที่ graphql ส่งมาให้เลยนะ | |
if (data.loading) { | |
return (<Spinner />) | |
} else { | |
return ( | |
<Container> | |
<Header><Title>Favorite Movie</Title></Header> | |
<Content> | |
<List | |
dataArray={data.allFilms.edges} | |
renderRow={this.renderRow.bind(this)} /> | |
<ModalView | |
title={this.state.title} | |
detail={this.state.detail} | |
visible={this.state.modalVisible} | |
onDismiss={()=> this.setModalVisible(false)}/> | |
</Content> | |
</Container>) | |
} | |
} | |
} | |
// query with graphql style.. | |
const gqlQuery = gql` | |
query { | |
allFilms { | |
edges { | |
node { | |
id | |
title | |
openingCrawl | |
director | |
releaseDate | |
} | |
} | |
} | |
} | |
` | |
// combind graphql to component | |
export default graphql(gqlQuery)(App) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment