现在我正在使用 HOC withApollo
,例如:
export default connect(mapStateToProps, mapDispatchToProps)(withApollo(withData(Browse)));
然后在该组件中:
render() {
const { client } = this.props;
<Button onPress={() => searchInterestsTab(client)} />
然后在该组件之外:
export const searchInterestsTab = (client) => {
^ 但是我发现这变得非常混乱,必须将它从我的组件传递到每个外部函数中。
我不能只使用:
const apolloClient = new ApolloClient({...})
export default apolloClient;
然后:
import apolloClient from './apolloClient';
到处?