[BUG] React-komposer Render Crazy amounts of times when collection updated


#1

Ok this is the scenario.

Lets say I have Facebook user posts page built. with posts and like buttons

this is the structure

MainPage
  Post
    Like
  Post
    Like

Like container code

function composer(props, onData) {
	let haveILiked = !!Likes.find({docId: props.menuitem._id, userId: Meteor.userId()}).count();

	onData(null, {haveILiked});
}

Lets say I have 50 posts on this page. And if I click on a like button for some reason the composer function runs 50 times before the actual like button press action happens. Any thoughts on this please ?

using this structure > https://github.com/kadira-samples/meteor-data-and-react/
this issue here too https://github.com/kadirahq/react-komposer/issues/2


#2

When are you calling the function?


#3

Not sure what you mean.

I call a method when the like button is clicked. So I expect the latency compensation to work and the like button to be updated instantly using the publication im subscribed to.

I use publish like this

Meteor.publish('likesAndPost', function(postId) {
   return [
     Posts.find({_id: postId}),
     Likes.find({postId: postId})
   ];
});

So everytime I call the like method which add or removes a like in the Likes collection I expect the Like record to updated ONCE.
Does that makes sense ?


#4

Should I just use https://atmospherejs.com/meteor/react-meteor-data ?

Not sure what to do here… if there are 100 likes buttons and if a like button is clicked I have to wait till the composer goes through all 100 like buttons before the screen is free to use… it just get stuck


#5

Used react-meteor-data and it stills rerender the like buttons 100 times :frowning:


#6

This blocks the UI too while the react-komposer is running…


#7

I’m struggling with something like this too.

Could someone knowledge please chime in?

Thanks :slight_smile: