Apollo调用填充数据道具的方式
graphql(withQLTag)(ReactComponent)
存在于组件类之外 .
但是,如果我想通过预定义查询的反应支持来控制我使用哪些数据,以便我可以重复使用多个数据模型的列表呢?(我知道列表视图必须从返回的所有数据中存在的属性中提取)
render() { return( <ReactComponent qlTag="Model1"> )...
有没有办法解决这个问题?
您可以根据需要制作尽可能多的包装组件:
import MyListComponent from './somewhere'; const ProductListComponent = graphql(ProductListQuery)(MyListComponent) const EventListComponent = graphql(EventListQuery)(MyListComponent) const SomethingElseListComponent = graphql(SomethingElseListQuery)(MyListComponent)
把 graphql 包装器想象成只是创建一个传递一些道具的组件 .
graphql
1 回答
您可以根据需要制作尽可能多的包装组件:
把
graphql
包装器想象成只是创建一个传递一些道具的组件 .