链接Github问题: https ://github.com/facebook/relay/issues/1218
我们遇到了Relay的奇怪行为.我会尽力解释我能做的最好的事情.
因此,我们有一个"主"中继容器,用于获取相应商店的数据,还包括Ticket容器和片段.故障单容器呈现具有过滤和排序的自定义表.所以你可以看到StoreFrom组件中的StoreTicketList容器导入所有必需的道具都像Store片段一样传递.
当您尝试过滤StoreList Ticket时会出现问题,我的意思是设置过滤器或排序中继变量.你会收到这个错误:
警告:RelayContainer:组件TicketList使用与用于获取片段的变量不同的变量进行渲染Store.片段是使用变量获取的{"first":5,"after":null,"last":null,"before":null,"sort":null,"filter":null},但是使用变量进行渲染{"first":5,"after":null,"last":null,"before":null,"sort":null,"filter":{"authorAccount":{"email":{"__e":"wrongEmail@email.com"}}}}.这可以指示两种可能性之一: - 父级在查询中设置正确的变量TicketList.getFragment('Store', {...})- 但在渲染组件时没有传递相同的变量.一定要通过将它们作为props传递给组件来告诉组件使用哪些变量:<TicketList ... first={...} after={...} last={...} before={...} sort={...} filter={...} />. - 您故意将虚假数据传递给此组件,在这种情况下忽略此警告.
但是那些过滤器/排序变量在StoreTicketList上并且它们不会从父容器传递到子容器,就像在这种情况下将容器存储到StoreListTicket容器一样.
export class StoreForm extends React.Component {
constructor(props) {
super(props);
const { Viewer: { store } } = props;
this.state = {
number: store && store.number !== null ? store.number : '',
};
}
handleInsert = (model) => {
console.log('Form mutation model : ', model); …Run Code Online (Sandbox Code Playgroud)