Releases: aws-amplify/amplify-ui
Releases · aws-amplify/amplify-ui
@aws-amplify/ui-vue@2.0.12
@aws-amplify/ui-react@2.2.2
@aws-amplify/ui-angular@2.0.12
@aws-amplify/ui@3.0.11
@aws-amplify/ui-vue@2.0.11
@aws-amplify/ui-react@2.2.1
@aws-amplify/ui-angular@2.0.11
@aws-amplify/ui@3.0.10
@aws-amplify/ui-vue@2.0.10
@aws-amplify/ui-react@2.2.0
Minor Changes
-
#1168
b32dd86bf
Thanks @wlee221! - This enablesuseAuthenticator
usage outside to access commonly requested authenticator context likeuser
androute
.First wrap your App with
Authenticator.Provider
:const App = ( <Authenticator.Provider> <MyApp /> </Authenticator.Provider> );
To avoid repeated re-renders, you can pass a function that takes in Authenticator context and returns an array of desired context values. This hook will only trigger re-render if any of the array value changes.
const Home = () => { const { user, signOut } = useAuthenticator((context) => [context.user]); return ( <> <h2>Welcome, {user.username}!</h2> <button onClick={signOut}>Sign Out</button> </> ); }; const Login = () => <Authenticator />; function MyApp() { const { route } = useAuthenticator((context) => [context.route]); return route === 'authenticated' ? <Home /> : <Login />; }