Pretty new on both Meteor and React so would like to know how to do getInitialState correctly after using FlowRouter.go the correct way.
My current setup is something like this
// Initial State
getInitialState: function () {
if (_.include(this.props.video.upvoters, this.props.userId)) {
return {like: true}
} else {
return {like: false};
}
},
// dissLike
handleDissLike: function (event) {
this.setState({dissLike: !this.state.dissLike});
Videos.update({_id: this.props.video._id}, {
$pull: {upvoters:this.props.userId
},
$inc: { votes: -1} });
setTimeout(() => {
FlowRouter.go('/video/' + this.props.next);
}, 2500) ;
},
So when accessing url directly or by href is will trigger getInitialState but when using FlowRouter.go it don’t seem to work.
If anyone would be kind to explain the correct way to do this is would be to huge help to get me on the right track.
using FR SSR
This is my route
FlowRouter.route('/video/:_id', {
name: 'video',
action: function(params, require) {
ReactLayout.render(VideoLayout, {
content: <VideoPage _id={params._id} />
});
}
});