iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🙄
Restricting Amplify Authenticator fields to Email and Password in React Native
The React Native version of Amplify Authenticator components have a bit of "parameter hell."
- Share components between SignUp and SignIn
- Use Email as an alias for Username
- Remove Phone Number authentication
I have identified the configuration to satisfy these three conditions by looking through the source code, so I am documenting it here.
export default withAuthenticator(App, {
usernameAttributes: "email",
signUpConfig: {
hiddenDefaults: ['phone_number'],
},
})
SignIn

SignUp

Where to look at the implementation
- https://github.com/aws-amplify/amplify-js/tree/bb60060d30c7463d1893b7678ebc18e959b46990/packages/aws-amplify-react-native/src/Auth
- https://github.com/aws-amplify/amplify-js/blob/bb60060d30c7463d1893b7678ebc18e959b46990/packages/aws-amplify-react-native/src/Auth/Authenticator.tsx
- https://github.com/aws-amplify/amplify-js/blob/bb60060d30c7463d1893b7678ebc18e959b46990/packages/aws-amplify-react-native/src/Auth/SignIn.tsx
- https://github.com/aws-amplify/amplify-js/blob/bb60060d30c7463d1893b7678ebc18e959b46990/packages/aws-amplify-react-native/src/Auth/SignUp.tsx
NOTE
JavaScript components are currently being unified across frameworks in Amplify UI, and the React Native version of Authenticator may also need to be migrated to the new version in the near future.
Discussion