meteor / react-tutorial

React Tutorial is the best place to learn how to use React and Meteor together
https://react-tutorial.meteor.com/
39 stars 87 forks source link

Update main.js - countAsync() #58

Closed JacobKGilbert closed 2 months ago

JacobKGilbert commented 2 months ago

When following the tutorial I ran into an issue where the app kept crashing after completing this step. The fix for this was changing "count()" to "countAsync()"

CLAassistant commented 2 months ago

CLA assistant check
All committers have signed the CLA.

StorytellerCZ commented 2 months ago

Good catch, but not the best solution. Using estimatedDocumentCount is probably the best. https://docs.meteor.com/api/collections.html#Mongo-Collection-estimatedDocumentCount

JacobKGilbert commented 2 months ago

Thank you @StorytellerCZ, I used countAsync due to the error given on the server. "error on boot.js Error: count() is not avaible on the server. Please use countAsync() instead."

I tried your approach and it worked as well to get rid of this error. We might need to see that the tutorial be updated with your option, as it is cleaner.

denihs commented 2 months ago

This is now updated in the V3 tutorial https://docs.meteor.com/tutorials/react/