Last active
December 14, 2016 18:36
-
-
Save ronal2do/08732f76c21a04bfa4903dfb86a7e68c 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 React, { Component } from 'react'; | |
import logo from './logo.svg'; | |
import './App.css'; | |
import Relay from 'react-relay'; | |
class App extends Component { | |
render() { | |
const { viewer } = this.props; | |
return ( | |
<div className="App"> | |
<div className="App-header"> | |
<img src={logo} className="App-logo" alt="logo" /> | |
<h2>Welcome to React</h2> | |
</div> | |
<p className="App-intro"> | |
To get started, edit <code>src/App.js</code> and save to reload. | |
</p> | |
<p>This came from Relay {viewer.id}</p> | |
<ul> | |
{viewer.posts.edges.map(({node}) => { | |
return ( | |
<li key={node.id}> | |
<h1>{node.title}</h1> | |
<p>{node.text}</p> | |
</li> | |
) | |
})} | |
</ul> | |
</div> | |
); | |
} | |
} | |
export default Relay.createContainer(App, { | |
fragments: { | |
viewer: () => Relay.QL` | |
fragment on Viewer { | |
id, | |
posts(first: 10) { | |
edges { | |
node { | |
id | |
title | |
text | |
} | |
} | |
} | |
} | |
`, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment