Make react komposer reactive when inputs don't change?

I have a meteor method that will insert a question. When I run the method, I can see that it gets inserted into my list of questions in the browser and then it immediately disappears. Normally, this would suggest to me that the server is rejecting the code that is running on the client. However, when I do a hard refresh, the item shows back up. This seems really strange to me, either it should only run in the browser, in the case of if I forgot to add the method to the server api/ or it should not be not responsive in the browser until a hard refresh but not both. I think the issue may be that I am getting my questions list from my parameters in the URL so they don’t change when I make the update. How can I make react komposer reactive in a case like this where I am pulling questions based on the URL parameters and I insert a new document? Thanks!

const composer = (params, onData) => {
      let subscription = Meteor.subscribe('questionsAnswersAdmin', params.courseSlug, params.lectureSlug);

      if (subscription.ready()) {
        const questions = Questions.find({}, {sort: {level:1}});
        const answers = Answers.find();

        onData(null, { questions, answers });

    export default composeWithTracker(composer, Loading)(LectureAdminLayout);

Are you looking directly at the collection data or the UI when it disappears?

I was looking at the UI when it disappears. I was able to fix the issue by making a tweak to how the subscription collects the questions documents. The core issue is that I changed this:

  let questions = Questions.find({lectureId: lecture._id});
  if(questions != null){
    let questionIds = (item) {
      return item._id;
    Questions.find({_id: {$in: questionIds}}),

to this:

 return Questions.find({lectureId: lectureId});

Obviously, in this context I seem insane for writing the first monstrosity in the first place but it made slightly more sense in the original context instead of this simplified one. I am still not entirely sure why the $in query doesn’t appear to be reactive but for now I am just glad that it works.

Thanks for the reply!

1 Like