React-Apollo:将组件状态传递给查询变量
React-Apollo : Passing components state to query variables
是否可以通过某种方式将组件状态注入到查询选项中?
道具之类的东西?
options: (ownProps : any, ownState???) =>{
console.log(a)
return {
variables: {
name : ownProps.name
id: ownState.id <-------------------------
}
为了回答我自己的问题,我发现 Apollo 的重新获取方法根据文档
The variables argument will replace variables used with either the query option or the query from your graphql()
这解决了问题。
是否可以通过某种方式将组件状态注入到查询选项中? 道具之类的东西?
options: (ownProps : any, ownState???) =>{
console.log(a)
return {
variables: {
name : ownProps.name
id: ownState.id <-------------------------
}
为了回答我自己的问题,我发现 Apollo 的重新获取方法根据文档
The variables argument will replace variables used with either the query option or the query from your graphql()
这解决了问题。