forked from tinytechnicaltutorials/amplify-cognito-quiz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
53 lines (45 loc) · 1.9 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import React from 'react';
import './App.css';
// Imports the Amplify library from 'aws-amplify' package. This is used to configure your app to interact with AWS services.
import {Amplify} from 'aws-amplify';
// Imports the Authenticator and withAuthenticator components from '@aws-amplify/ui-react'.
// Authenticator is a React component that provides a ready-to-use sign-in and sign-up UI.
// withAuthenticator is a higher-order component that wraps your app component to enforce authentication.
import { Authenticator, withAuthenticator } from '@aws-amplify/ui-react';
// Imports the default styles for the Amplify UI components. This line ensures that the authenticator looks nice out of the box.
import '@aws-amplify/ui-react/styles.css';
// Imports the awsExports configuration file generated by the Amplify CLI. This file contains the AWS service configurations (like Cognito, AppSync, etc.) specific to your project.
import awsExports from './aws-exports';
// Imports the Quiz component from Quiz.js for use in this file.
import Quiz from './Quiz';
// Configures the Amplify library with the settings from aws-exports.js, which includes all the AWS service configurations for this project.
Amplify.configure(awsExports);
function App() {
return (
<div className="App">
<Authenticator>
{({ signOut }) => (
<main>
<header className='App-header'>
{/* Quiz Component */}
<Quiz />
{/* Sign Out Button */}
<button
onClick={signOut}
style={{
margin: '20px',
fontSize: '0.8rem',
padding: '5px 10px',
marginTop: '20px'
}}
>
Sign Out
</button>
</header>
</main>
)}
</Authenticator>
</div>
);
}
export default withAuthenticator(App);