Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Graphql 如何使用react钩子在一个地方处理阿波罗错误?_Graphql_React Hooks_React Apollo_Apollo Client - Fatal编程技术网

Graphql 如何使用react钩子在一个地方处理阿波罗错误?

Graphql 如何使用react钩子在一个地方处理阿波罗错误?,graphql,react-hooks,react-apollo,apollo-client,Graphql,React Hooks,React Apollo,Apollo Client,我正在使用React with hooks+GraphQL My app.jsx: import { onError } from 'apollo-link-error'; ... const httpLink = ... const errorLink = onError(err => console.log(err)) const terminatingLink = split(...httpLink, errorLink) const client = new ApolloClien

我正在使用React with hooks+GraphQL

My app.jsx:

import { onError } from 'apollo-link-error';
...
const httpLink = ...
const errorLink = onError(err => console.log(err))
const terminatingLink = split(...httpLink, errorLink)
const client = new ApolloClient({
    link: ApolloLink.from([terminatingLink])
    ...
})
<ApolloProvider client={client}>
    <ErrorProvider>
    </ErrorProvider>
</ApolloProvider>
这看起来像是过度编码,因为我太频繁了。 但我不知道如何在从“apollo link error”导入的onError()函数中只在AppAlloclient中分派一次错误。我不能在那里用钩子。 我应该在这种特殊情况下使用redux吗? 提前谢谢

const [createTeam] = useMutation(createTeamQ, {
    onError: (err) => { dispatchError(err) }
})