我已经开始学习 graphql(在此处添加中继),所以我按照步骤运行中继,我创建了我的第一个查询:
function fetchQuery(operation, variables) {
return fetch("http://localhost:3000/graphql", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
query: operation.text,
variables
})
}).then(response => {
return response.json();
});
}
const modernEnvironment = new Environment({
network: Network.create(fetchQuery),
store: new Store(new RecordSource())
});
class ClientList extends React.PureComponent {
render() {
return (
<QueryRenderer
envieronment={modernEnvironment}
query={graphql`
query ClientListQuery {
clients {
name
cnpj
ie
}
}
`}
variables={{}}
render={({ error, props }) => {
console.log("props", props);
return <h1>hi</h1>;
}}
/>
);
}
}
但它失败了,控制台上出现以下错误:
未捕获的类型错误:无法在更新类组件(react-dom)的constructClassInstance(react-dom.development.js:11447)的新ReactRelayQueryRenderer(ReactRelayQueryRenderer.js:74)的fetchQueryAndComputeStateFromProps(ReactRelayQueryRenderer.js:214)处读取未定义的属性'unstable_internal'。 development.js:13144) 在 beginWork (react-dom.development.js:13824) 在 performUnitOfWork (react-dom.development.js:15863) 在 workLoop (react-dom.development.js:15902) 在 HTMLUnknownElement.callCallback ( react-dom.development.js:100) 在 Object.invokeGuardedCallbackDev (react-dom.development.js:138) 在 invokeGuardedCallback (react-dom.development.js:187)
谢谢。