I started trying to learn Meteor a few weeks ago, everything was going great, then I hit a snag. I have been stuck on this step for so long and making no progress. All I want to be able to do is make a button that will display how many times a user pressed it, save that info in the db and display it next time they log in. I have looked all over and tried many different ways to do it, but none worked. If some one could plz point me to somewhere I can learn this, or lend any kind of guidance, it would be greatly appreciated. Thanks.
Have you completed the tutorial?
We have all of our new engineers go through this tutorial:
It’s pretty solid!
Break it down and then tackle each step at a time (I imagine you have already been trying it - maybe an explanation/summary of what you have tried that didn’t work would help us answer better).
Off the top of my mind:
1 - Create a Meteor method that gets called every time the button is clicked
2 - The method should update the db (either a separate collection or the Meteor.users collection) with the number of clicks (use the mongo operator
3 - Write a publication to ensure the client is getting the data from the collection above (new collection or Meteor.users - specifically the field that you are incrementing)
4 - Use
withTracker to subscribe to the publication and pass the data to your React component (assuming you are using React)
5 - Display the count passed through to props from the withTracker on step 4
Thanks but I still keep hitting a problem, when I get to step “5.4 Import Task component from the body”, it causes the body template to disappear. I have checked every step 6 times now, what am I overlooking?
No idea. You need to share your code to get a good answer to that…
Thanks but I still keep hitting a problem, when I get to step “5.4 Import Task component from the body”, it causes the body template to disappear. I have checked every step 6 times now, what am I overlooking? If I remove the tasks.html and task.js and just leave it on body.html and main.js, then everything works fine. The problem is with import ‘./tasks.js’. I have read others having this same problem but none of the fixes they used work for me. When I keep the tasks template in the body.html and the template helpers in body.js, then the ReactiveDict() wont work in the next step. Thanks again for any ideas or help
Make a repo with the code so someone can take a look