I am reading a React doc, https://reacttraining.com/react-router/web/example/auth-workflow, and trying to understand the following piece of code:
Looks like a the function definition happens in a json object, but my understanding is that we can't have funciton inside json
const fakeAuth = {
isAuthenticated: false,
authenticate(cb) {
this.isAuthenticated = true;
setTimeout(cb, 100); // fake async
},
signout(cb) {
this.isAuthenticated = false;
setTimeout(cb, 100);
}
};