当我尝试在反应路线中检查授权或无授权时出现此错误
错误: “超过最大更新深度。当组件重复调用componentWillUpdate或componentDidUpdate内部的setState时,可能会发生这种情况。React限制了嵌套更新的数量,以防止无限循环”
App.js
render() {
return (
<View style={styles.container1}>
<ScrollView>
<View style={styles.container}>
<View style={styles.SectionStyle}>
<Image source={require('../assets/padlock.png')} style={styles.ImageStyle} />
<TextInput
style={{flex:1}}
placeholder="Current Password"
underlineColorAndroid="transparent"
secureTextEntry
selectionColor={'#002B60'}
returnKeyType={'next'}
blurOnSubmit={false}
onSubmitEditing={() => this.passwordRef.focus()}
onChangeText={(oldpassword) => this.setState({oldpassword})}
/>
</View> </View>
</View>
</ScrollView>
</View>
);
}
}
Auth.js
<NonAuth>
<Switch>
<Route exact path='/login' component={Login} />
<Route exact path='/sign-up' component={SignUp} />
<Route exact path='/' component={Home} />
</Switch>
</NonAuth>
<Auth>
<Switch>
<Route exact path='/questions' render={props => <QCom {...props}} />
</Switch>
</Auth>
NonAuth.js
import React from 'react'
import { Redirect } from 'react-router-dom'
import {
connect,
} from 'react-redux'
const Auth = (props) => {
console.log( props )
return props.currentUser? props.children : <Redirect to={'/asks'}/>
}
const mapStateToProps = state => {
return {currentUser:state.currentUser,}
}
export default connect(mapStateToProps)(Auth)