I've had this issue pop up in one form or another over the years, and I finally figured out how to put it to words. Consider the following code:
import React, {Component} from "react";
import aFunction from "./Function";
export default class SomeComponent extends Component{
constructor(props){
super(props);
}
render(){
console.log(aFunction);
debugger;
return(
<div>some stuff</div>
)
}
}
The console.log() call will print information about aFunction, but if I type "aFunction" into the browser console I get a reference error. Why does this happen? Shouldn't console.log and the browser console via debugger have access to the same scope?
EDIT: I should clarify that I'm getting a reference error after allowing the "debugger" to occur before typing "aFunction". I'm not trying to call up block scoped variables after render() has completed.