Code snippet:
class Box extends React.Component{
render() {
params = new URLSearchParams(this.props.location.search);
abc = params.get('abc');
console.log(params);
Error via "Create React App":
Why am I getting an error here?
In non-strict mode, an assignment to an undeclared symbol is implicitly treated as creating a global variable. In strict mode, that's an error.
I just checked Reacts compiled code and it has "use strict";
at the top. So yes, React restricts undeclared variables.