Amplify-js: Load signup component at first withAuthenticator

Created on 10 Jul 2018  路  8Comments  路  Source: aws-amplify/amplify-js

Signin page is what loads first instead of sign up when using withAuthenticator. Can I load the signup page at first?

React bug

Most helpful comment

This might be super late, as @yasithph has probably solved his problem, but I solved it using defaultProps:

let authenticatedComponent = withAuthenticator(component, null, AuthFlow, federated, AuthTheme);
authenticatedComponent.defaultProps = { authState: 'signUp' }
return authenticatedComponent;

All 8 comments

I am afraid you can't for now.

The component loads with the initial state sign-in. Is there a way to change the state for example using changeState? @powerful23

Hey maybe you can try using Authenticator directly and pass the authState into Authenticator manually like: <Authenticator authState='signUp'/> so the initial state would be signUp instead of signIn.

Thanks. I will check this and let you know whether this works. @powerful23

@yasithph does this work for you? I am going to close this issue. Feel free to reopen if you still have this issue.

Setting authState='signUp' doesn't work, because when the Authenticator component is mounted it calls Auth.currentAuthenticatedUser() and sets then goes through the signout flow, resulting in authState being set to signIn again. See: https://github.com/aws-amplify/amplify-js/blob/master/packages/aws-amplify-react/src/Auth/Authenticator.jsx#L58

As far as I can tell, there isn't a way to show the sign up page declaratively.

@jagregory good catch, will try to fix this later on.

This might be super late, as @yasithph has probably solved his problem, but I solved it using defaultProps:

let authenticatedComponent = withAuthenticator(component, null, AuthFlow, federated, AuthTheme);
authenticatedComponent.defaultProps = { authState: 'signUp' }
return authenticatedComponent;
Was this page helpful?
0 / 5 - 0 ratings