3

我正在尝试创建一个实时搜索结果组件(延迟加载一个)。它第一次完美运行,但重新获取不会更新数据。我在标签中看到了请求和响应Network!所以它确实获取了数据,但它不将其提供给组件!

知道为什么吗?

import React, { Component } from 'react';
import {
    createRefetchContainer,
    graphql,
} from 'react-relay';

import ProfileShow from './ProfileShow';

class ProfileList extends Component {
    render() {
        console.log("rendering....", this.props)
        return (
            <div className="row">
                <input type="text" onClick={this._loadMe.bind(this)} />
                {this.props.persons.map((person) => {
                    return (
                        <div className="col-md-3">
                            <ProfileShow person={person} />
                        </div>
                    );
                })}

            </div>
        );
    }
    _loadMe(e) {
        const refetchVariables = fragmentVariables => ({
            queryStr: e.target.value,
        });

        this.props.relay.refetch(refetchVariables, null, (...data) => {
            console.log(data)
        });
    }
}

const FragmentContainer = createRefetchContainer(
    ProfileList,
    {
        persons: graphql.experimental`
        fragment ProfileList_persons on Person @relay(plural: true) {
            fullname
            number
            email
            pic
        }
    `
    },
    graphql.experimental`
    query ProfileListRefetchQuery($queryStr: String!) {
        talentList(query: $queryStr) {
        ...ProfileList_persons
        }
    }
  `,
);

export default FragmentContainer;
4

0 回答 0