I have a function called setupChannel that takes "socket" as a parameter. I am using redux-thunk so setupChannel returns an anonymous function with dispatch and getState as parameters. Inside that anonymous function, the debugger says socket is undefined unless I make specific reference of socket in the function.
Here socket is undefined when I use the debugger:
export const setupChannel = socket => {
return (dispatch, getState) => {
debugger;
}
}
Here socket is defined when I console.log it
export const setupChannel = socket => {
return (dispatch, getState) => {
console.log(socket);
}
}
Socket is also defined when I simply call a method on it:
export const setupChannel = socket => {
return (dispatch, getState) => {
socket.connect();
}
}
So my question remains, why is it undefined when I pop the debugger in or possibly when I don't reference it?