Skip to content

Commit

Permalink
Make withAuthenticator HOC configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
rlmartin committed Jan 21, 2018
1 parent 911abdf commit 2d823e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
}));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -91,7 +91,9 @@ export function withAuthenticator(Comp, includeGreetings=false) {

return <Authenticator
{...this.props}
hideDefault={authenticatorComponents.length > 0}
onStateChange={this.handleAuthStateChange}
children={authenticatorComponents}
/>
}
}
Expand Down

0 comments on commit 2d823e9

Please sign in to comment.