useEffect(()=>{console.log("leftDragger", leftDragger);},[leftDragger])
let [slidesCount, setSlidesCount] = useState(document.querySelectorAll('.slick-list .slick-slide:not(.slick-cloned)').length);
const MainNavigator = createDrawerNavigator(
{
Main: {
screen: PostNavigator,
navigationOptions: {
drawerLabel: 'Главная'
},
initialParams={{ type: 'Главная'}}
},
Category_Politik: {
screen: PostNavigator,
navigationOptions: {
drawerLabel: 'Политика'
},
initialParams={{ type: 'Политика'}}
},
Category_Ekonomik: {
screen: PostNavigator,
navigationOptions: {
drawerLabel: 'Экономика'
},
initialParams={{ type: 'Экономика'}}
},
AboutUs: {
screen: AboutUsNavigator,
navigationOptions: {
drawerLabel: 'Об издании'
}
}
},
{
initialRouteName: 'Main',
drawerBackgroundColor: '#D2D2D2',
}
)
import React, { Component } from 'react';
import './App.css';
var convert = require('xml-js');
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
class App extends Component {
constructor(props) {
super(props);
this.state = {
posts: []
}
}
componentDidMount() {
var result1 = convert.xml2json(xml, {compact: true, spaces: 4});
var result2 = convert.xml2json(xml, {compact: false, spaces: 4});
const url = "";
fetch(url)
.then(response => response.json())
.then(json => this.setState({ posts: json }))
}
render() {
const { posts } = this.state;
return (
<div className="container">
{posts.map((post) => (
<div className="card" key={post.id}>
#{post.id} {post.title}
<p className="text">{post.body}</p>
</div>
))}
</div>
);
}
}
class Videomain extends React.Component {
state = {
videos: [],
selectedVideo: null,
}
onVideoSelect = (video) => {
this.setState({selectedVideo: video});
}
async componentDidMount() {
this.addVal('Start')
const token = await localStorage.getItem("token") //тут нужно подождать выполнения async await
let login = true;
if(token === null) {
login = false
}
this.state = {
login
}
}
addVal = async (searchWord) => {
const response = await connect.get('connect', {
params: {
part: 'snippet',
}
});
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>
);
}
}