我正在使用带有npm软件包(具有生成的代码)和使用它的移动软件包的Yarn工作区。
当尝试从导入的查询进行调用时,我收到无效的挂接调用。在该组件中使用其他任何钩子(即useState)都可以正常工作。
我的移动软件包的package.json导入:
Pybind11
我在core / src上有一个index.js文件,该文件具有:
"@workspace-library/core": "1.0.0",
我这样导入查询:
export * from "./generated/graphql";
export { apollo, useAuth, withAuth };
以防万一,我可以在我生成的/graphql.jsx中看到useArticlesQuery,
import {
useArticlesQuery
} from "@workspace-library/core";
const SidebarArticles: FunctionComponent<{ props: any }> = (props: any) => {
const [test, setTest] = useState("false");
const data = useArticlesQuery({
fetchPolicy: "no-cache",
notifyOnNetworkStatusChange: true,
});
return (
<View>
<Text>Heyhey</Text>
</View>
);
};
环境:
其他上下文 有问题的错误:
export function useArticlesQuery(baseOptions) {
return ApolloReactHooks.useQuery(ArticlesDocument, baseOptions);
}
答案 0 :(得分:-2)
我遇到了同样的问题。不过使用 useQuery
是可行的。