I try to Implement some stuff with React, Relay and GraphQL, but I faced a Problem I dont understand and where i cant find a solution.
First I created a RootQuery and had one Component and it worked well. Now I created a Sub Component with an own fragment an i get this Error:
relay.js:1799 Warning: RelayContainer: Expected prop
room
to be supplied toRoomList
, but gotundefined
. Pass an explicitnull
if this is intentional.
In the Networkrequest I see all the requested Data.
Here is some code:
Root Query
const RoomQuery = {
room: (Component) => Relay.QL`
query {
room {
${Component.getFragment('room')},
}
}
`
};
Route
<Route name="rooms" path="/rooms" component={Rooms} onEnter={requireAuth} queries={RoomQuery}/>
Relay Container
export default Relay.createContainer(Rooms, {
fragments: {
room: () => Relay.QL`
fragment on Room {
title,
description,
publicKeys,
takenKeys,
image_filename,
subRoomsCount,
owner {
fullName
},
${RoomList.getFragment('room')},
}
`,
}
});
Relay Sub Container
export default Relay.createContainer(RoomList, {
fragments: {
room: () => Relay.QL`
fragment on Room {
subRooms{
title,
description,
publicKeys,
takenKeys,
image_filename,
availableKeys,
owner {
fullName
},
subRoomsCount
}
}
`,
}
});
In my React Component I use this Sub React Component like this:
<RoomList></RoomList>
I dont know if I understand something wrong but I thougt that Relay will load the Data and fill it in this.props, but there is only a relay Object.
Thanks for your help :)
Greetings
Ronny Gerndt
Ok, I found a solution for the problem. I just needed to change
<RoomList></RoomList>
to
<RoomList room={this.props.room}></RoomList>
and Relay gives me my right Filled subroom List.
I hope someone else will find this useful ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With