刷新页面时不会在componentWillMount上触发功能

时间:2018-01-21 14:10:23

标签: javascript reactjs

嗯,为什么每次刷新页面时,validateAccount函数都不再运行? 只有我通过路由器链接

才会运行
static void Main(string[] args)
{
    string path = @"C:\path\kilroy_was_here.mp3";

    // instantiate the Application object
    dynamic shell = Activator.CreateInstance(Type.GetTypeFromProgID("Shell.Application"));

    // get the folder and the child
    var folder = shell.NameSpace(Path.GetDirectoryName(path));
    var item = folder.ParseName(Path.GetFileName(path));

    // get the item's property by it's canonical name. doc says it's a string
    string bpm = item.ExtendedProperty("System.Music.BeatsPerMinute");
    Console.WriteLine(bpm);
}

1 个答案:

答案 0 :(得分:2)

据我所知,我不认为你可以在类声明中使用arrow函数。箭头函数将在任何其他函数内部工作,但不在类声明中。

尝试将其更改为:

validateAccount(userObj) {
        if(userObj){
            this.userRef.once('value').then(snap => {
                if(snap.hasChild(userObj.uid)){
                    this.getRole(userObj);
                } else {
                    this.userRef.child(userObj.uid).push({
                        email: userObj.email,
                        role: 'Member'
                    });
                }
            });
        }