javascript - Parse React - Observe Objects created by Parse.User.current() -


i'm using excellent parse-react library parse , reactjs work nicely (n.b i've been playing around few hours apologies if i've misunderstood of basics of reactjs). going until wanted query table objects created current user (parse.user.current())

the observe method works correctly on load , view rendered correct objects (the objects created current user). if mutate data , add new object view doesn't re-render.

abstracted code:

module.exports = react.createclass({     mixins: [parsereact.mixin],     getinitialstate: function() {         return {             selected: null         };     },     observe: function() {         return {             places: (new parse.query('place'))                         .equalto('user', parse.user.current())                         .descending('createdat')         };     },     clickhandler: function(event) {          var id = event.target.id;         if (id === 'new') {             parsereact.mutation.create('place', {                 name: 'new place',                 user: parse.user.current()             }).dispatch();         } else if(id.indexof('place:') === 0) {             this.setstate({                 selected: id.substring(6)             });         }      },     render: function() {          var = this;         var navitems = this.data.places.map(function(place) {             return (                 <usernavitem id={place.id} key={place.id} label={place.name} selected={that.state.selected === place.objectid} onclick={that.clickhandler}/>             );         });          return (             <ul>                 {navitems}                 <usernavitem id='new' label='+ new place' onclick={this.clickhandler} />             </ul>         );      } }); 

if remove part of query specifies user:

.equalto('user', parse.user.current()) 

then works; new place objects appear in list when added.

has got idea i'm doing wrong?

am using parse queries incorrectly? seems strange getting data pertaining current user bit of pain when seems such common use case?

thanks!

the solution call .refreshqueries() method of component when new object created in parse described here.

my updated example:

            parsereact.mutation.create('place', {                 name: 'new place',                 user: parse.user.current()             })             .dispatch()             .then(function() {                 this.refreshqueries();             }.bind(this)); 

thanks joshua sierles on over parsereact github repo pointing me solution. if on joshua i'll give credit if post answer here :d


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -