I was banging my head going through again and again for a typo why my list is not showing up in my SideNav (a Materialize CSS component). Then I took the same subscription code to my home page and console logged it and now I get the array of objects in console. Before when I tested on SideNav component, it was just empty array.
I’m using TrackerReact, whatever the latest version is, why is this happening? And how do I fix it?
import React, {Component} from 'react';
import TrackerReact from 'meteor/ultimatejs:tracker-react';
export default class Home extends TrackerReact(Component) {
constructor() {
super();
this.state = {
subscription: {
userList: Meteor.subscribe('userList')
}
}
}
componentWillUnmount() {
this.state.subscription.userList.stop();
}
userList() {
return List.find().fetch();
}
render() {
console.log(this.userList());
return (
<div>
<h4>Home</h4>
</div>
);
}
}
Above is the working one. The not working one is the exact same except it’s placed in a SideNav component.