React: Only Showing a Button if All Meteor Data Has Specific Attribute

Hi guys,

I’ve been trying to create functionality in a React component where a ‘Save’ button is only shown if all of the meteor data has a specific attribute set to true.

I have meteor data set to ‘rules’ in getMeteorData():

rules: Answers.find({answerType: 'rule'}, {sort: {createdAt: -1}}).fetch()

I only want to show a ‘Save’ button for a list of rules if each and every one of the rules has their ‘confirmed’ attribute set to true. I’ve tried looping over each item and setting an overall ‘allConfirmed’ state to being false if any aren’t confirmed but I’m not sure how to make this reactive. User’s will actively be ‘confirming’ and ‘unconfirming’ their rules in a child component which updates the collection.

I’ve been banging my head against this problem for the second half of today and any help would very much be appreciated.


  • Ben

Can you use a count variable to indicate how many rules confirmed? Then use rules.length === this.state.comfirmed ? SaveButton : null} in your render().