So I'm trying to figure out Relay.js. I conjured simple app that basically imitates example on Relay's website. However although I've managed to get rid of errors in both consoles (node and chrome), my component doesn't receive fragments I specified in Raley.Container. I have no idea, where the problem could be, as my app looks pretty much like Relay's example.
Note that map method on this.props.companies
isn't available as it is an object, with 1 property, that is __dataId__.
First Component
class App extends React.Component {
render() {
return (
<div>
{this.props.companies.map((comapny => <Company company={company} />))}
</div>
);
}
}
export default Relay.createContainer(App, {
fragments: {
companies: () => Relay.QL`
fragment on Companies {
companies { ${Company.getFragment('company')} }
}
`,
},
});
Second component
class Company extends React.Component {
render() {
return (
<div>
<h1>{this.props.comapany.name}</h1>
</div>
);
}
}
export default Relay.createContainer(Company, {
fragments: {
company: () => Relay.QL`
fragment on Company {
__id,
name
}
`,
},
});
And my Route
class AppHomeRoute extends Relay.Route {
static routeName = 'Comapnies';
static queries = {
companies: (Component) => Relay.QL`
query {
companies { ${Component.getFragment('companies')} }
}
`,
};
}
Any ideas?
__dataID__
. – Battlefield