Reactjs 我可以用一个变量包装多个变量吗

Reactjs 我可以用一个变量包装多个变量吗,reactjs,firebase,Reactjs,Firebase,在学习reactjs和firebase的同时制作网站 我对reactjs和firebase非常陌生。我认为学习它们最好的方法是在学习它们的同时做一个项目 actionCodeSettings = { // After password reset, the user will be give the ability to go back // to this page. url: "http://localhost:3000/logs#/react-auth-ui/sig

在学习reactjs和firebase的同时制作网站

我对reactjs和firebase非常陌生。我认为学习它们最好的方法是在学习它们的同时做一个项目

actionCodeSettings = {
    // After password reset, the user will be give the ability to go back
    // to this page.
    url: "http://localhost:3000/logs#/react-auth-ui/sign-in",
    handleCodeInApp: false
  }
我试了如下

constructor() {
super();
this.state = {
  email: "",
  isOpen: false,
  actionCodeSettings = {
    // After password reset, the user will be give the ability to go back
    // to this page.
    url: "http://localhost:3000/logs#/react-auth-ui/sign-in",
    handleCodeInApp: false
  }
};
this.handleChangeEmail = this.handleChangeEmail.bind(this);

this.handleSendPasswordResetEmail = this.handleSendPasswordResetEmail.bind(
  this
);
}


这可能是一个愚蠢的问题。但我现在的情况是这样的,我想提高自己。任何帮助都是感激的。谢谢

这个。状态只是一个对象。它遵循以下语法:

this.state = { key1: val1, 
               key2: val2 }
因此,简单地用a替换=就可以了

this.state = {
  actionCodeSettings : {
    url: "http://localhost:3000/logs#/react-auth-ui/sign-in",
    handleCodeInApp: false
  }
};

除此之外,还请检查这个问题:它详细说明了当您使用这样的嵌套对象时如何更新状态,但它也给出了您可能不想这样做的原因。你自己去看四个人