我想用火力權威性與Login
和Signup
反應母語,但我得到了一個黃色的錯誤:設置的很長一段時間的計時器,即多分鐘
設置定時器用於長時間時間(即多分鐘)是Android上的一個性能和正確性問題,因爲它使定時器模塊保持喚醒狀態,只有在應用程序處於前臺時才能調用定時器。有關更多信息,請參閱(https://github.com/facebook/react-native/issues/12981)。 (鋸片超時時間111862ms)
我該如何解決這個問題?
我不想忽視這一點,我想理解這個錯誤,並用最好的和標準的方式解決這個問題。
這是我的代碼:
export default class Login extends Component {
constructor(props) {
super(props)
this.state = {
email: '',
password: '',
response: ''
}
this.signUp = this.signUp.bind(this)
this.login = this.login.bind(this)
}
async signUp() {
try {
await firebase.auth().createUserWithEmailAndPassword(this.state.email, this.state.password)
this.setState({
response: 'Account Created!'
})
setTimeout(() => {
this.props.navigator.push({
id: 'App'
})
}, 1500)
} catch (error) {
this.setState({
response: error.toString()
})
}
}
async login() {
try {
await firebase.auth().createUserWithEmailAndPassword(this.state.email, this.state.password)
this.setState({
response: 'user login in'
})
setTimeout(() => {
this.props.navigator.push({
id: 'App'
})
})
} catch (error) {
this.setState({
response: error.toString()
})
}
}
render() {
return (
<View style={styles.container}>
<View style={styles.containerInputes}>
<TextInput
placeholderTextColor="gray"
placeholder="Email"
style={styles.inputText}
// onChangeText={(email) => this.setState({ email })}
onChangeText={(email) => {console.log(email);}}
/>
<TextInput
placeholderTextColor="gray"
placeholder="Password"
style={styles.inputText}
password={true}
onChangeText={(password) => this.setState({ password })}
/>
</View>
<TouchableHighlight
onPress={this.login}
style={[styles.loginButton, styles.button]}
>
<Text
style={styles.textButton}
>Login</Text>
</TouchableHighlight>
<TouchableHighlight
onPress={this.signUp}
style={[styles.loginButton, styles.button]}
>
<Text
style={styles.textButton}
>Signup</Text>
</TouchableHighlight>
</View>
)
}
}
我報以谷歌火力地堡隊:(https://github.com/firebase/firebase-js-sdk/issues/97)
你檢查了這個lib的源代碼嗎?警告沒有顯示,因爲作者確實使用了上面提到的技巧:D https://github.com/invertase/react-native-firebase/search?utf8=%E2%9C%93&q=ignoredYellowBox&type= – Sephy
@Sephy:我有沒有檢查lib的源代碼,但我用它爲我的應用程序,它運作良好。而且我也沒有做你發現的伎倆。 –
有些人需要使用帶有React Native的JavaScript firebase,例如,Expo不支持react-native-firebase。 – jamrizzi