amplify-js: AuthState is not exported from @aws-amplify/ui-components

Describe the bug In a typescript based react app, when using the AmplifyAuthenticator, i’d like to change the initalAuthState parameter, described here https://docs.amplify.aws/ui/auth/authenticator?framework=react#prop-initial-auth-state. However, the enum AuthState from ui-components is not exported so typescript fails with an error similar to: node_modules/@aws-amplify/ui-components/dist/types/components"' declares 'AuthState' locally, but it is not exported.

To Reproduce Steps to reproduce the behavior:

  1. Create a CRA app with a typescript template
  2. import AmplifyAuthenticator into the App.tsx.
  3. add the initalAuthState property to AmplifyAuthenticator like <AmplifyAuthenticator usernameAlias="email" initialAuthState={AuthState.SignUp>
  4. See error

Expected behavior User should be able to import AuthState enum and use it for initalAuthState

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 18 (5 by maintainers)

Most upvoted comments

Using @aws-amplify/ui-react@unstable worked for me as well. Thanks

Nope, I got another error now.

./node_modules/@aws-amplify/ui-components/dist/esm-es5/Translations-59947173.js
Attempted import error: 'AuthErrorStrings' is not exported from '@aws-amplify/auth'.

Also getting this error when using version: ^0.2.19 in package.json, installed version 0.2.19

Attempted import error: 'AuthErrorStrings' is not exported from '@aws-amplify/auth'.

Edit / update: This error is from using withAuthenticator from @aws-amplify/auth in a Next.js page. I just tested this in a SPA using Create React App and it works fine.

Edit # 2: After removing my node_modules and re-installing, it also works fine in my Next.js app.

Sorry about the delay. The unstable package worked for me, thanks.