本文介绍了ParseReact没有接收到数据(错误:this._subscriptions [name] .dispose不是函数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将parse用作我的应用程序后端,但是我无法确保使用react()方法正确地连接了parse(),因为我可以使用ParseReact对数据进行突变,但是我无法通过observe()方法接收数据.突变.

I am using parse as my app back-end, but I am unable to receive data with the observe() method, although I'm sure that react is properly connect with parse, because I can mutate data with the ParseReact.mutation.

import React from 'react';
import Parse from 'parse';
import ParseReact from 'parse-react';

const pinRegister = React.createClass({
  mixins: [ParseReact.Mixin],

  observe() {
    return {
      pins: (new Parse.Query('Pin'))
  },
  render() {
    return {
      <ul>
       {this.data.pins.map(function(pin) {
        return <li>{pin}</li>;
       })}
      </ul>
    }
  }        
});

在控制台上,我收到以下消息:与'ws://mywsaddress:8080/parse'的WebSocket连接失败:在收到握手响应之前连接已关闭",并且this.data.pins不确定,我检查了数据在parse-dashboard中,并且Pin类具有正确的数据.

On the console I receive this message: "WebSocket connection to 'ws://mywsaddress:8080/parse' failed: Connection closed before receiving a handshake response" and the this.data.pins gets undefined,I checked the data in parse-dashboard and the Pin class has the properly data.

我在解析服务器上添加了liveQuery,并且套接字错误停止了,但是我仍然无法接收数据,在chrome的控制台上,我得到了:未捕获的TypeError:this._subscriptions [name] .dispose不是一个函数,而这个问题来自于parse-react的代码和平:

I add the liveQuery on my parse server, and the socket error stopped, but I'm still unable to receive data, on chrome's console I get this: Uncaught TypeError: this._subscriptions[name].dispose is not a function, and this problem comes from this peace of code from parse-react:

_unsubscribe: function _unsubscribe() {
    for (var name in this._subscriptions) {
      this._subscriptions[name].dispose();
    }
    this._subscriptions = {};
  },

推荐答案

您没有正确包含ParseReact.Mixin.将"mixis"替换为"mixins".

You are not included ParseReact.Mixin correctly. Replace "mixis" on "mixins".

mixins: [ParseReact.Mixin]

这篇关于ParseReact没有接收到数据(错误:this._subscriptions [name] .dispose不是函数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 06:38