必须两次按提交才能调用Firebase函数

时间:2019-08-18 14:08:23

标签: javascript firebase react-native google-cloud-firestore google-cloud-functions

我是Firebase的新手。我正在尝试将数据更新到我的Firebase Firestore数据库。

问题:每当我使用“提交按钮”提交表单时,都必须按两次以使其执行Firestore功能(尽管它确实具有console.log功能)

理想行为:我应该按一次在线提交按钮。

    handleSubmit(){   
            console.log(this.state);
            fb.firestore().collection("businessDetails").add({
                category: this.state.bCategory,
                description: this.state.bDescription,
                name: this.state.bName,
                since: this.state.bEstablished,
                phone: this.state.bPhone,
                uid: this.state.uid
            })
            .then(()=>{
                console.log("User succesfully submitted, data recorded");
            })
            .catch((error)=>{
                console.log(error);
            })
        }


    <Footer>
        <FooterTab>
            <Button onPress={()=>this.handleSubmit()} 
                disabled={!this.state.flag} full 
                style={(this.state.flag)?styles.submitButton:[]}
            >
                <Text style={styles.buttonText}>Submit and Signup</Text>
            </Button>
        </FooterTab>                        
    </Footer>

0 个答案:

没有答案