Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
尝试在MST(mobx状态树)操作中创建firebase用户_Firebase_React Native_Mobx_Mobx State Tree - Fatal编程技术网

尝试在MST(mobx状态树)操作中创建firebase用户

尝试在MST(mobx状态树)操作中创建firebase用户,firebase,react-native,mobx,mobx-state-tree,Firebase,React Native,Mobx,Mobx State Tree,我正在尝试使用MST操作在firebase中创建新用户 我的代码如下所示: .actions((self => ({ createUserWithEmailPassword: flow(function*(password: string) { console.log('creating user'); yield firebase.auth().setPersistence(firebase.auth.Auth.Pe

我正在尝试使用MST操作在firebase中创建新用户

我的代码如下所示:

.actions((self => ({
    createUserWithEmailPassword:
        flow(function*(password: string) {
            console.log('creating user');
            yield firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL);
            console.log('set Persistence');
            const user = yield firebase.auth().createUserWithEmailAndPassword(self.email, password);
            console.log('CREATED USER', user);
            self.uid = user.uid;
        })
}));
它确实创建了一个用户,但它不会在createUserWithEmailAndPassword调用之前进行。i、 e.它永远不会控制“创建的用户”`

我在用户上也有onPatch控制台,但它也不会显示用户更新

我厌倦了操纵假api调用

let res = yield fetch("https://randomapi.com/api/6de6abfedb24f889e0b5f675edc50deb?fmt=raw&sole")
这很好用


createUserWithEmailAndPassword似乎有问题,但我无法解决。

您的代码应该可以正常工作,但您也可以尝试一下

createUserWithEmailPassword(password: string) {   
  flow(function*() {
            console.log('creating user');
            yield firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL);
            console.log('set Persistence');
            const user = yield firebase.auth().createUserWithEmailAndPassword(self.email, password);
            console.log('CREATED USER', user);
            self.uid = user.uid;
        })() // <--- check this
}
首先将flowfunction*password:string{}的内部内容包装到try。。。捕获以确保它不会抛出错误。
createUserWithEmailPassword(password: string) {
        const run = flow(function*() {
            console.log('creating user');
            yield firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL);
            console.log('set Persistence');
            const user = yield firebase.auth().createUserWithEmailAndPassword(self.email, password);
            console.log('CREATED USER', user);
            self.uid = user.uid;
        })

        run()
}