Relay Framework uncaught TypeError: this.props.relay.commitUpdate is not a function
Relay Framework uncaught TypeError: this.props.relay.commitUpdate is not a function
我正在学习 Relay 框架和 GraphQL。我正在关注 tutorial from its official website. 在该教程中,我将使用 GraphQL 突变构建游戏。游戏的目标是在 9 个正方形的网格中找到隐藏的宝藏。当我在服务器上 运行 时一切都很好,但是当我对其中一个网格执行单击操作时,应用程序抛出错误:
Uncaught TypeError: this.props.relay.commitUpdate is not a function
从控制台的日志中,我可以清楚地看到 this.props.relay
中没有 commitUpdate()
函数,但我感到困惑,因为在 Relay's playground 中,我可以看到有this.props.relay
.
中的 commitUpdate()
函数
有什么想法吗?
经过几个小时的观察,终于解决了这个问题。我不知道这是否是一个好的解决方案。我将 this.props.relay.commitUpdate
更改为 Relay.Store.commitUpdate
。该应用随后会按预期运行。
@asubanovsky Relay Starter Kit seems to be outdated compared with the Relay Documentation,所以更好的解决方案是将 'react-relay' 的版本从 0.8.1 更新到 0.9.0,然后 npm install
,撤消更改你已经到达 Relay.Store.commitUpdate
,你就可以出发了。
我正在学习 Relay 框架和 GraphQL。我正在关注 tutorial from its official website. 在该教程中,我将使用 GraphQL 突变构建游戏。游戏的目标是在 9 个正方形的网格中找到隐藏的宝藏。当我在服务器上 运行 时一切都很好,但是当我对其中一个网格执行单击操作时,应用程序抛出错误:
Uncaught TypeError: this.props.relay.commitUpdate is not a function
从控制台的日志中,我可以清楚地看到 this.props.relay
中没有 commitUpdate()
函数,但我感到困惑,因为在 Relay's playground 中,我可以看到有this.props.relay
.
commitUpdate()
函数
有什么想法吗?
经过几个小时的观察,终于解决了这个问题。我不知道这是否是一个好的解决方案。我将 this.props.relay.commitUpdate
更改为 Relay.Store.commitUpdate
。该应用随后会按预期运行。
@asubanovsky Relay Starter Kit seems to be outdated compared with the Relay Documentation,所以更好的解决方案是将 'react-relay' 的版本从 0.8.1 更新到 0.9.0,然后 npm install
,撤消更改你已经到达 Relay.Store.commitUpdate
,你就可以出发了。