提问者:小点点

如何将firebase db与react-native连接


这是我发送给Firebase的提交表单:

enter code heresubmitForm = async () => {
    const reg = /^\+?3?8?(0\d{9})$/

    if(!this.state.phone.match(reg)) {
      Alert.alert('Error', 'Wrong phone number !')
    } else if( this.state.username.length < 1) {
      Alert.alert('Error', 'Username has to be not empty !')
    } else { 
      await AsyncStorage.setItem('userPhone', this.state.phone)
      User.phone = this.state.phone
      firebase.database().ref('users/' + User.phone).set({ username: this.state.username })
      this.props.navigation.navigate('App')
    }
  }

共1个答案

匿名用户

我看到两个错误

  1. 错误与firebase无关,而是与Async-Storage包有关。请尝试使用最新的。
  2. 卸载组件之前尚未清除firebase订阅。

async-storage的最新链接您可以使用https://react-native-async-storage.github.io/async-storage/docs/install