Hi everyone,
I run into a problem when trying to implement more React into my Meteor application.
At the moment I am using this.state to change my menu and navigate to different pages.
The problem I have now has to do with my composer that compiles my collection. It is only being called once when the page loads, but I want it to reload every time my state element activeCity get’s updated.
How am I able to achieve this result?
This is my current composer element:
const composer = (props, onData) => {
const subscription = Meteor.subscribe('comments');
if (subscription.ready()) {
const activeCity = props.activeCity;
const comments = Comments.find({approved: true, city: activeCity }, {sort: {timestamp: -1}}).fetch();
onData(null, { comments });
}
};
export default composeWithTracker(composer, Loading)(CommentsList);
So I have 3 different states of activeCity and I want this composer to re-render every time my city changes. But I have no idea how to achieve this result.
Before it would just re-render everytime I load a new page, but because everything is now happening on the same page this doesn’t happen anymore.