React 是否限制使用未声明的变量?

does React restrict usage of undeclared variables?

代码片段:

class Box extends React.Component{
  render() {
    params = new URLSearchParams(this.props.location.search);
    abc = params.get('abc');
    console.log(params);

通过 "Create React App" 出错:

为什么我在这里收到错误消息?

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.

我刚刚检查了 Reacts 编译代码,它的顶部有 "use strict";。所以是的,React 限制未声明的变量。