【发布时间】:2020-01-21 10:59:59
【问题描述】:
所以我正在尝试使用 react native 和 aws-amplify 来构建具有一个代码库的 Web 和移动应用程序。现在我刚刚将withAuthenticator 组件添加到我的应用程序中,该组件在移动部分上运行良好,但是当我在浏览器中运行网络应用程序时,我无法输入身份验证字段,即如果我点击它,光标就会出现并且令人惊讶的是,如果我单击并按住,只要按住鼠标按钮,我就可以突然打字。所以在那之后我尝试创建我的自定义身份验证器,它在移动设备上运行良好,但在网络上它返回错误class constructors must be invoked with '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 extends SignIn这是正确的吗?我通常导入class MySignIn extends React.Component的类 -
解决了非常感谢
-
你能告诉我为什么这行得通,因为根据文档应该使用我使用的东西。谢谢