2017-02-17 47 views
1

该反应阿波罗调用来填充数据的方式丙有没有办法通过反应道具传递阿波罗查询选择?

graphql(withQLTag)(ReactComponent) 

存在组件类的外部。

但是,如果我想通过预定义的查询来控制哪些数据通过反应道具来使用,以便我可以重复使用多个数据模型的列表?(我知道列表视图必须从所有存在的属性数据返回)

render() { 
     return(
      <ReactComponent qlTag="Model1"> 
     )... 

有没有方法可以解决这个问题?

回答

1

只要你喜欢你可以让尽可能多的包裹部分组成:graphql包装的

import MyListComponent from './somewhere'; 

const ProductListComponent = graphql(ProductListQuery)(MyListComponent) 
const EventListComponent = graphql(EventListQuery)(MyListComponent) 
const SomethingElseListComponent = graphql(SomethingElseListQuery)(MyListComponent) 

想象的那样只是创建通过一些道具的组件。

相关问题