Skip to content

Instantly share code, notes, and snippets.

@fortruce
Created August 15, 2015 19:04
Show Gist options
  • Select an option

  • Save fortruce/f8c1ae5b5681800c4bc1 to your computer and use it in GitHub Desktop.

Select an option

Save fortruce/f8c1ae5b5681800c4bc1 to your computer and use it in GitHub Desktop.
React Relay refs Violation
import Relay from 'react-relay';
export default class extends Relay.Route {
static path = '/';
static queries = {
game: (Component) => Relay.QL`
query {
game {
${Component.getFragment('game')},
},
}
`,
};
static routeName = 'AppHomeRoute';
}
import React from 'react';
import Relay from 'react-relay';
class Application extends React.Component {
render() {
return (
<div>
Hello World!
</div>
);
}
}
export default Relay.createContainer(Application, {
fragments: {
game: () => Relay.QL`
fragment on Game {
turnsRemaining
}
`
}
});
import React from 'react';
import ReactDOM from 'react-dom';
import Relay from 'react-relay';
import AppHomeRoute from './routes/AppHomeRoute';
import Application from './components/Application';
class Root extends React.Component {
render() {
return (
<Relay.RootContainer
Component={ Application }
route={ new AppHomeRoute() }
/>
);
}
}
ReactDOM.render(
<Root />,
document.getElementById('container')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment