This piece of code is at the bottom of a component named 'Block'.
export default theBlockContainer = createContainer(({ params }) => {
return {
voteStatus:Meteor.user()['listofvoted'],
}
}, Block);
The code above works perfect, but I want to refactor it.
Is there any way for me to store the "voteStatus:Meteor.user()['listofvoted']" bit into a variable before the return statement, such that the return statement need to only return the variable?
Ideally something like this...
export default theBlockContainer = createContainer(({ params }) => {
let temp = voteStatus:Meteor.user()['listofvoted'],
return {
temp;
}
}, Block);
I think I'm missing something fundamental because it seems like a straight forward task, however I have tried this numerous times and in equally numerous ways but only to receive compiler errors.
this.setState({ voteStatus: Meteor.user()['listofvoted'] }). This is using the state of your 'Block' component to store the variable. And then you should be able toreturn this.state.voteStatus;