我正在从relay 10to迁移,relay 11并且在调用refetchfrom时遇到奇怪的错误useRefetchableFragment。这是我的组件:
const EditClient: FC<Props> = ({ clientRef }) => {
const [refetchData, refetch] = useRefetchableFragment<EditClientContactsRefetchQuery, any>(
graphql`
fragment EditClient_refetch_client on Client
@refetchable(queryName: "EditClientContactsRefetchQuery") {
contacts {
...ContactList_contact
}
}
`,
clientRef
);
return (
<>
<ContactList contact={refetchData.contacts} />
<button onClick={() => refetch({}, { fetchPolicy: 'network-only' })>
refetch
</button>
</>
);
}
然后我单击按钮,它重新获取 graphql 查询但也抛出一个错误:
react_devtools_backend.js:2430 警告:中继:意外调用的
refetch优先级高于. 看起来您尝试在高优先级更新下调用,但可能导致组件挂起的更新应该以正常优先级安排。确保你是从钩子里面打电话的。EditClient_refetch_clientuseRefetchableFragment()refetchrefetchstartTransition()useSuspenseTransition()
什么是 ahigh priority update以及如何将onClick事件放到normal priority? 中继文档没有说明如何调用refetch函数。
如果我将refetchcall 放入setTimeout回调中,我不会收到任何错误,但这感觉不对。