if (nextProps.keydown.event) {
constructor(){
this.state = {redirect:true}
}
componentWillReceiveProps(nextProps) {
if (nextProps.keydown.event && this.state.redirect ===true) {
this.setState({
redirect:false
})
const key = nextProps.keydown.event.which;
const location = nextProps.location.pathname;
const history = nextProps.history;
if (key === 39 && location === '/index') {
this.timeOut(history, '/index/loc1');
} else if (key === 39 && location === '/index/loc1') {
this.timeOut(history, '/index/loc2');
} else if (key === 37 && location === '/index/loc1') {
this.timeOut(history, '/index');
} else if (key === 37 && location === '/index/loc2') {
this.timeOut(history, '/index/loc1');
}
}
}
componentWillReceiveProps(nextProps){
console.log("nextProps",nextProps)
}
if (location== '/index/loc1') {
console.log("loc1")
} else if (location== '/index/loc2'){
console.log("loc3")
}else{
console.log("else",typeof location)
}
if (k === 37 && location=== '/index/loc1') {
history.push('/index');
}
else if (k === 39 && location=== '/index') {
history.push('index/loc1');
}else{
}
switch(location){
case k === 37 && '/index/loc1':
alert( '/index/loc1' );
break;
case k === 39 && '/index/loc2':
alert( '/index/loc2' );
break;
}