Javascript 不能通过反应路由器传递道具
我让类GetProfile在render中扩展React.Component和返回状态。我想用react router获取道具GetProfile,但我收到了消息 元素类型无效:应为字符串(对于内置组件) 或类/函数(用于复合组件),但得到:未定义。你 可能忘记了从定义组件的文件中导出组件, 或者您可能混淆了默认导入和命名导入 类GetProfile扩展了React.Component{ .... render(){ 返回( {React.cloneElement(this.props.children,{ 数据:this.state.data, 部门:这个,国务院 }) } ) } } 导出默认GetProfile; 在Router.js中,这是我的代码Javascript 不能通过反应路由器传递道具,javascript,reactjs,react-props,Javascript,Reactjs,React Props,我让类GetProfile在render中扩展React.Component和返回状态。我想用react router获取道具GetProfile,但我收到了消息 元素类型无效:应为字符串(对于内置组件) 或类/函数(用于复合组件),但得到:未定义。你 可能忘记了从定义组件的文件中导出组件, 或者您可能混淆了默认导入和命名导入 类GetProfile扩展了React.Component{ .... render(){ 返回( {React.cloneElement(this.props.chil
import Home from './components/Home';
import GetProfile from './action/GetProfile';
....
<GetProfile>
<Authenticated exact path="/home" render={(props) => <Home {...props.data}/>}/>
</GetProfile>
....
import Home from./components/Home';
从“/action/GetProfile”导入GetProfile;
....
}/>
....
尝试导入React
从“React”导入React
类GetProfile扩展了React.Component{
....
render(){
返回(
{React.cloneElement(this.props.children,{
数据:this.state.data,
部门:这个,国务院
})
}
)
}
}
导出默认GetProfile;
尝试导入React
从“React”导入React
类GetProfile扩展了React.Component{
....
render(){
返回(
{React.cloneElement(this.props.children,{
数据:this.state.data,
部门:这个,国务院
})
}
)
}
}
导出默认GetProfile;
import Home from './components/Home';
import GetProfile from './action/GetProfile';
....
<GetProfile>
<Authenticated exact path="/home" render={(props) => <Home {...props.data}/>}/>
</GetProfile>
....
try by importing React
import React from 'react'
class GetProfile extends React.Component{
....
render(){
return(
<div>
{React.cloneElement(this.props.children, {
data: this.state.data,
department : this.state.department
})
}
</div>
)
}
}
export default GetProfile;