Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs ×;TypeError:无法读取属性';地点';未定义的_Reactjs - Fatal编程技术网

Reactjs ×;TypeError:无法读取属性';地点';未定义的

Reactjs ×;TypeError:无法读取属性';地点';未定义的,reactjs,Reactjs,我是js新手,我在this.state={location:props.history.location}行中遇到一个错误 asTypeError:无法读取未定义的属性“location”,如何解决提供以下我的代码的问题: function App() { return ( //BEM naming convention <div className="app"> <div className

我是js新手,我在
this.state={location:props.history.location}行中遇到一个错误
as
TypeError:无法读取未定义的属性“location”
,如何解决提供以下我的代码的问题:

function App() {

    return (
        //BEM naming convention
        <div className="app">
            <div className="app_body">
                <Router>
                    <Switch>
                        <Sidebar />
                        <Route path="/root/:roomId">
                            <Chat />
                        </Route>
                        <Route path="/">
                            <h1>Home screen</h1>
                            <Chat />
                        </Route>
                    </Switch>
                </Router>
            </div>
        </div>

    );
}
函数应用程序(){
返回(
//边界元命名约定
主屏幕
);
}

你能把你要执行的代码片段放出来吗?如果您能详细说明您期望的产量,我将不胜感激

据我所知,您可能需要在
return()之前尝试添加以下内容:

如果使用类组件,请在
return()
代码块之前的
render()
方法中尝试此操作:

const { location } = this.props;

然后你可以继续使用
位置

你能把你要执行的代码片段放出来吗?如果您能详细说明您期望的产量,我将不胜感激

据我所知,您可能需要在
return()之前尝试添加以下内容:

如果使用类组件,请在
return()
代码块之前的
render()
方法中尝试此操作:

const { location } = this.props;
然后您可以继续使用
位置