React native 类构造函数必须使用';新';反应本机错误

React native 类构造函数必须使用';新';反应本机错误,react-native,aws-amplify,React Native,Aws Amplify,所以我尝试使用react native和aws amplify构建一个只有一个代码库的web和移动应用程序。现在,我刚刚在我的应用程序中添加了with authenticator组件,该组件在移动设备上运行良好,但当我在浏览器中运行web应用程序时,我无法在“身份验证”字段中键入内容,即如果我单击该字段,光标将出现,并且令人惊讶地消失,尽管如果我单击并按住该组件,我会突然能够键入我所需的内容按住鼠标键。因此,在那之后,我尝试创建一个自定义验证器,该验证器在mobile上运行良好,但在web上它返

所以我尝试使用react native和aws amplify构建一个只有一个代码库的web和移动应用程序。现在,我刚刚在我的应用程序中添加了
with authenticator
组件,该组件在移动设备上运行良好,但当我在浏览器中运行web应用程序时,我无法在“身份验证”字段中键入内容,即如果我单击该字段,光标将出现,并且令人惊讶地消失,尽管如果我单击并按住该组件,我会突然能够键入我所需的内容按住鼠标键。因此,在那之后,我尝试创建一个自定义验证器,该验证器在mobile上运行良好,但在web上它返回了一个错误
类构造函数必须用“new”调用
。我的代码在下面,希望有人能帮我。谢谢

  class MySignIn extends SignIn {

    constructor(props) {
      super(props);   
      this.state = {
          username: null,
          password: null,
          error: null
      }
      this.checkContact = this.checkContact.bind(this);
      this.signIn = this.signIn.bind(this);
  }


    render() {
      if (this.props.authState !== 'signIn') {
        return null;
      }
      return(
        <View style={{flex:1, backgroundColor: 'blue'}} behavior="padding">
        <Text>Stuff and Stuff</Text>
    </View>
      );
    }
  }

  export default withAuthenticator(Signout, false, [
    <MySignIn/>,
    <ConfirmSignIn/>,
    <VerifyContact/>,
    <SignUp/>,
    <ConfirmSignUp/>,
    <ForgotPassword/>,
    <RequireNewPassword />
  ]);
class MySignIn扩展了SignIn{
建造师(道具){
超级(道具);
此.state={
用户名:null,
密码:null,
错误:null
}
this.checkContact=this.checkContact.bind(this);
this.signIn=this.signIn.bind(this);
}
render(){
如果(this.props.authState!=='sign'){
返回null;
}
返回(
诸如此类
);
}
}
使用验证器导出默认值(注销、假、[
,
,
,
,
,
,
]);

类别MySignIn扩展SignIn
是否正确?我通常导入MySignIn扩展React.Component的

这是有效的,因为他们从

import { ConfirmSignIn, ConfirmSignUp, ForgotPassword, RequireNewPassword, SignIn, SignUp, VerifyContact, withAuthenticator } from 'aws-amplify-react';
因此,这是一个自定义类组件,因此它可以工作

// This is my custom Sign in component
class MySignIn extends SignIn {
  render() {
    ...
  }
} 

这很有效。希望对您有所帮助

class MySignIn extensed SignIn
是否正确?我通常会导入MySignIn Expands React.Component的
类来解决这个问题,非常感谢你能告诉我为什么这样做,因为根据我使用的文档人们应该使用它。谢谢