This works:
// Toggle the state every second
setInterval(
() => {
this.setState(previousState => {
return { isShowingText: !previousState.isShowingText };
});
}, 1000);
}
This does not work:
// Toggle the state every second
setInterval(
function() {
this.setState(previousState => {
return { isShowingText: !previousState.isShowingText };
});
}, 1000);
}
I am expecting that if i replace () => {...}
with function() {...}
the above code should still work, but instead, I am getting the error that "undefined is not a function". Isn't the arrow syntax just shorthand for writing the function keyword?