Reputation:
class TransitionComp extends Component{
Duration = ()=>{
return Math.floor(Math.random() * Math.floor(3000))
}
render(){
console.log(this.Duration)
return(
)
}
}
The console is returning
ƒ () {
return Math.floor(Math.random() * Math.floor(3000));
}
instead of an integer. If I don't use "this", Duration will become undefined.
Upvotes: 0
Views: 48
Reputation: 5162
The correct way to invoke the function is:
console.log(this.Duration());
Upvotes: 2