From 2d823e974532f3f5dc72111f6ae51342d826d251 Mon Sep 17 00:00:00 2001 From: Ryan Martin Date: Fri, 29 Dec 2017 16:42:55 -0500 Subject: [PATCH] Make `withAuthenticator` HOC configurable --- .../aws-amplify-react-native/dist/components/auth/index.js | 6 ++++-- .../aws-amplify-react-native/src/components/auth/index.js | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/aws-amplify-react-native/dist/components/auth/index.js b/packages/aws-amplify-react-native/dist/components/auth/index.js index 1bbf9d7cc1c..f0c5145553d 100644 --- a/packages/aws-amplify-react-native/dist/components/auth/index.js +++ b/packages/aws-amplify-react-native/dist/components/auth/index.js @@ -33,7 +33,7 @@ const logger = new Logger('auth components'); export { Authenticator, AuthPiece, SignIn, ConfirmSignIn, SignUp, ConfirmSignUp, ForgotPassword, RequireNewPassword, VerifyContact, Greetings }; -export function withAuthenticator(Comp, includeGreetings = false) { +export function withAuthenticator(Comp, includeGreetings = false, authenticatorComponents = []) { class Wrapper extends React.Component { constructor(props) { super(props); @@ -79,7 +79,9 @@ export function withAuthenticator(Comp, includeGreetings = false) { } return React.createElement(Authenticator, _extends({}, this.props, { - onStateChange: this.handleAuthStateChange + hideDefault: authenticatorComponents.length > 0, + onStateChange: this.handleAuthStateChange, + children: authenticatorComponents })); } } diff --git a/packages/aws-amplify-react-native/src/components/auth/index.js b/packages/aws-amplify-react-native/src/components/auth/index.js index a8838bece8c..82b58acf048 100644 --- a/packages/aws-amplify-react-native/src/components/auth/index.js +++ b/packages/aws-amplify-react-native/src/components/auth/index.js @@ -42,7 +42,7 @@ export { Greetings }; -export function withAuthenticator(Comp, includeGreetings=false) { +export function withAuthenticator(Comp, includeGreetings=false, authenticatorComponents = []) { class Wrapper extends React.Component { constructor(props) { super(props); @@ -91,7 +91,9 @@ export function withAuthenticator(Comp, includeGreetings=false) { return 0} onStateChange={this.handleAuthStateChange} + children={authenticatorComponents} /> } }