【发布时间】:2018-09-13 01:08:08
【问题描述】:
这是我的代码文件。
import React from 'react'
import { gql } from 'apollo-boost'
import { Query } from 'react-apollo'
const CATEGORY_QUERY = gql`Some query here`
const handleOnCategoryTouch = (id) => {
//Again call the query
}
const Home = () => (
<Query
query={CATEGORY_QUERY}
variables={{ limit: 20, cursor: "", idcategory: 0 }}
>
{({ loading, error, data }) => {
if (loading) return <Text>Loading...</Text>;
if (error) return <Text>Error :(</Text>;
return (
<Categories
categories={data.get_discovery_kol_data.categories}
content={data.get_discovery_kol_data.postKol}
onCategoryTouch={handleOnCategoryTouch}
/>
)
}}
</Query>
这里的Categories 是一个将类别呈现为UI 中的芯片的组件。点击那个芯片,我们得到 categoryId。现在我想用最新的 id 调用CATEGORY_QUERY 并更新现有结果,怎么做?
我正在使用
"apollo-boost": "^0.1.3",
"graphql": "^0.13.2",
"react": "^16.3.0-alpha.1",
"react-apollo": "^2.1.0-beta.3",
"react-native": "0.54.2",
【问题讨论】:
标签: react-native apollo