-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.tsx
More file actions
72 lines (63 loc) · 2.15 KB
/
index.tsx
File metadata and controls
72 lines (63 loc) · 2.15 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import * as React from 'react';
import * as smoothscroll from 'smoothscroll-polyfill';
import { register } from 'register-service-worker';
import Home from '@/Components/Home';
import Header from '@/Components/Header';
import Footer from '@/Components/Footer';
import AlertBadge from '@/Components/AlertBadge';
import './reset.css';
import './theme.css';
import './typography.css';
smoothscroll.polyfill();
type State = {
badgeMessage: string | null;
};
export default class App extends React.Component<{}, State> {
state = {
badgeMessage: null,
};
componentWillMount() {
const showMessage = (message: string) => {
this.setState({
badgeMessage: message,
});
};
register(`${process.env.PUBLIC_URL}service-worker.js`, {
ready(registration) {
console.log('Service worker is active.');
},
registered(registration) {
console.log('Service worker has been registered.');
},
cached(registration) {
showMessage('🎉 You can now visit the website while offline!');
console.log('Content has been cached for offline use.');
},
updatefound(registration) {
console.log('New content is downloading.');
},
updated(registration) {
showMessage('✨ Refresh the page to see the new changes!');
console.log('New content is available; please refresh.');
},
offline() {
showMessage('⌛️ No internet connection! The schedule might be out of date');
console.log('No internet connection found. App is running in offline mode.');
},
error(error) {
console.error('Error during service worker registration:', error);
},
});
}
render() {
const { badgeMessage } = this.state;
return (
<div>
<Header />
<Home />
<Footer />
<AlertBadge message={badgeMessage} />
</div>
);
}
}