【发布时间】:2018-06-19 00:41:28
【问题描述】:
我有一个项目,我使用redux,react-apollo,我想知道,是否有机会通过减速器提供从react-apollo 到redux 的数据。伪代码如下。
...
import { graphql } from 'react-apollo'
import gql from 'graphql-tag'
const query = gql`
{
...
}`
/* Function, which I want to returns data from graphql */
const getDate = () => {
return graphql(query)
}
/*---- Reducer ----*/
export default (state = getDate(), action) => {
console.log(state) // function, instead data
...
}
【问题讨论】:
-
是的,可以通过在
gql配置对象的props函数中调度事件来实现。这有点奇怪,但那是唯一真正可以吸引它的地方。或者就此而言,目标组件的生命周期事件。有意义吗?
标签: javascript reactjs facebook-graph-api redux react-apollo