gpt4 book ai didi

javascript - ApolloClient 不是构造函数 react-apollo

转载 作者:行者123 更新时间:2023-11-30 11:28:02 24 4
gpt4 key购买 nike

我正在关注 this tutorial并尝试实现 graphQl。以下行存在问题:

const client = new ApolloClient();

奇怪的是,我在 react-apollo GitHub 页面中找不到任何相关内容。我做错了什么愚蠢的事情。

import React, { Component } from 'react';
import ChannelsList from './ChannelsList.js';
import './App.css';

import {
ApolloClient,
gpl,
graphql,
ApolloProvider
} from 'react-apollo';


//issue with this line
const client = new ApolloClient();

const channelsListQuery = `
query ChannelsListQuery {
channels {
id,
name
}
}
`;

const ChannelsListWithData = graphql(channelsListQuery)(ChannelsList);

class App extends Component {
render() {
return (
<ApolloProvider client={client}>
<ChannelsListWithData />
</ApolloProvider>
);
}
}

export default App;

最佳答案

提供一个直截了当的答案——ApolloClient 不再是 react-apollo 包的一部分,而是成为它自己的一个包:apollo -客户端

您可能还会看到它是从 apollo-boost 导入的,这是一种便利,“包括一些我们 [Apollo 的作者] 认为对使用 Apollo Client 进行开发必不可少的包。”

关于javascript - ApolloClient 不是构造函数 react-apollo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47282972/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com