Last active
December 24, 2015 14:57
-
-
Save z81/47ad0a57ce9c527c2f0a to your computer and use it in GitHub Desktop.
This file contains 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 from 'React'; | |
import ReactDOM from 'react-dom'; | |
import Relay from 'react-relay'; | |
let mountNode = root; | |
class Users extends React.Component { | |
constructor(props) { | |
console.error(props); | |
super(props); | |
} | |
render() { | |
console.error(props); | |
return <ul> | |
{this.props.users.map( | |
u => <div>{u.name}</div> | |
)} | |
</ul>; | |
} | |
} | |
Users = Relay.createContainer(Users, { | |
fragments: { | |
users: () => Relay.QL` | |
fragment on viewer { | |
users { | |
id | |
name | |
} | |
} | |
` | |
}, | |
}); | |
class UsersHomeRoute extends Relay.Route { | |
static routeName = 'Home'; //${Component.getFragment('users')} | |
static queries = { | |
users: (Component) => Relay.QL` | |
query { | |
viewer { ${Component.getFragment('users')} } | |
} | |
`, | |
}; | |
} | |
ReactDOM.render( | |
<Relay.RootContainer | |
Component={Users} | |
route={new UsersHomeRoute()} | |
/>, | |
root | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment