我使用parse-react库。我做第一个查询来检索数据,在另一个组件中我做同样的查询但是使用equalTo("用户","用户连接")所有查询都正常但在第二个查询之后当我尝试在项目上做Mutation.Destroy我得到了这个错误。
UpdateChannel.js:146 Uncaught Error: Object is attached to a nonexistant subscription
这是简短的示例代码:
AppWrapper.react.js:
var Parse = require('parse').Parse;
var ParseReact = require('parse-react');
var React = require('react');
var Wall = require('./Wall.react.js');
var Gallery = require('./Gallery.react.js');
var contents = [
<Wall/>,
<Gallery/>
];
var AppWrapper = React.createClass({
getInitialState: function() {
return {
current_page:0
};
},
changePage:function(pageidx){
this.setState({
current_page:pageidx
});
},
change:function(){
if(this.state.current_page == 0){
this.setState({
current_page:1
});
}else{
this.setState({
current_page:0
});
}
},
render: function() {
return (
<div>
<button onClick={this.change} className="btn btn-primary">change</button>
{contents[this.state.current_page]}
</div>
);
}
});
module.exports = AppWrapper;
Wall.react.js
var Parse = require('parse').Parse;
var React = require('react');
var ParseReact = require('parse-react');
var Wall = React.createClass({
mixins: [ParseReact.Mixin],
getInitialState: function() {
return {
type:this.props.type
};
},
observe: function() {
var query = (new Parse.Query("PictureItem")).descending("createdAt").include("user");
return {
items:query
};
},
delete:function(){
var id = this.data.items[0].id;
ParseReact.Mutation.Destroy(this.data.items[0]).dispatch();
},
render: function() {
console.log(this.data.items);
return (
<div className="container">
<button className="btn btn-primary" onClick={this.delete}>T</button>
<div className="col-lg-10 col-lg-offset-1">
<h1>WALL</h1>
// Normale I render rows that map this.data.items
</div>
</div>
);
}
});
module.exports = Wall;
Gallery.react.js
var Parse = require('parse').Parse;
var React = require('react');
var ParseReact = require('parse-react');
var Gallery = React.createClass({
mixins: [ParseReact.Mixin],
observe: function() {
var userPointer = {"__type": "Pointer",
"className": "_User",
"objectId": "6O8YNufFK9"};
var query = (new Parse.Query("PictureItem")).descending("createdAt").include("user").equalTo("user",userPointer);
return {
items:query
};
},
delete:function(){
var id = this.data.items[0].id;
ParseReact.Mutation.Destroy(id).dispatch();
},
render: function() {
console.log(this.data.items);
return (
<div className="container">
<button className="btn btn-primary" onClick={this.delete}>T</button>
<div className="col-lg-10 col-lg-offset-1">
<h1>Gallery</h1>
// Normale I render rows that map this.data.items
</div>
</div>
);
}
});
module.exports = Gallery;
我真的不知道问题是什么......