не работают дочерние компоненты.
Выдается ошибка еypeError: Cannot read property 'map' of undefined
проверяю ничего не приходит в дочерние компоненты.
Почему ничего не приходит?
class Videomain extends React.Component {
constructor(props) {
super(props);
this.state = {
videos: [],
selectedVideo: null,
}
this.onVideoSelect = this.onVideoSelect .bind(this)
this.addVal = this.addVal .bind(this)
const token = localStorage.getItem("token")
// eslint-disable-next-line no-unused-vars
let login = true;
if(token === null) {
login = false
}
this.state = {
login
}
console.log(login)
}
onVideoSelect = (video) => {
this.setState({selectedVideo: video});
}
componentDidMount() {
this.addVal('Start')
}
addVal = async (searchWord) => {
const response = await j.get('name', {
params: {
part:'name'
}
});
this.setState({videos: response.data.items, selectedVideo: response.data.items[0]})
}
render() {
if (this.state.login === false) {
return <Redirect to="/"/>
}
const {videos, selectedVideo} = this.state
return (
<div className="app" style={styleApp}>
<Row justify="center">
<Col xs={20} sm={20}>
<Link to="/logout">" Выход</Link>
<Search onSubmit={this.addVal}/>
</Col>
</Row>
<Row justify="center">
<Col xs={24} sm={14}>
<Video video={selectedVideo}/>
</Col>
<Col xs={24} sm={6}>
<VideoItems videos={videos} onVideoSelect={this.onVideoSelect}/>
</Col>
</Row>
</div>
);
}
}