Skip to content

Instantly share code, notes, and snippets.

@z81
Last active December 24, 2015 14:57
Show Gist options
  • Save z81/47ad0a57ce9c527c2f0a to your computer and use it in GitHub Desktop.
Save z81/47ad0a57ce9c527c2f0a to your computer and use it in GitHub Desktop.
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