为了拥有默认的身份验证屏幕,我只能这样做(https://github.com/aws-samples/aws-mobile-react-native-starter):
import { withAuthenticator } from 'aws-amplify-react-native';
export default withAuthenticator(App);
而且我得到了非常丑陋的默认开箱即用登录屏幕:
然后docs说我无法修改默认值,我必须创建自己的(https://github.com/aws-samples/aws-mobile-react-native-starter):
您可以使用此高阶组件,也可以构建自己的UI并使用Amplify的API .
但他们也说,我可以自定义默认登录屏幕(https://github.com/aws/aws-amplify/blob/master/README.md):
AWS Amplify将为用户注册和登录等常见用例提供可自定义的UI .
问题是,我们可以自定义默认屏幕吗?如果我们想要一些花哨的东西,我们必须创建自己的屏幕?
3 回答
根据the docs,您应该能够将您的应用程序包装在HOC(
Authenticator
)中,而不是使用withAuthenticator
.所有Amplify Authenticator组件都可以与aws-amplify-react-native分开导入 . 您可以 copy the source code 将repo(https://github.com/aws-amplify/amplify-js/tree/master/packages/aws-amplify-react-native/src)添加到您自己的项目 modify it 并从那里导入 . *如果你想获得其他框架的包 - React,Vue,Angular等,请访问这里https://github.com/aws-amplify/amplify-js/tree/master/packages/aws-amplify-react-native .
目前,在我的项目中,我正在自定义
SignUp, SignIn and ConfigrmSignUp
组件,如下所示 . 这是创建自己的UI的建议方式,它与放大验证器无缝协作 .点击此处了解更多信息:https://aws-amplify.github.io/docs/js/authentication#create-your-own-ui
我有同样的问题,为aws-amplify定制signUp和SignIn组件,所以我创建了这个lib(aws-amplify-react-custom-ui) . 这是自定义signIn的示例:
更多信息:https://github.com/ysfmag/aws-amplify-react-custom-ui