-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
38 lines (34 loc) · 1.44 KB
/
index.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
import 'react-app-polyfill/stable'
import React from 'react'
import ReactDOM from 'react-dom'
import './index.css'
import App from './App'
import * as serviceWorkerRegistration from './serviceWorkerRegistration'
import reportWebVitals from './reportWebVitals'
import { onServiceWorkerUpdate } from '@3m1/service-worker-updater'
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
)
// Creates a custom event and fires it on the document
// Internal components can listen to it
const dispatchCustomEvent = (name, detail) => {
const event = new CustomEvent(name, { detail })
document.dispatchEvent(event)
}
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://cra.link/PWA
serviceWorkerRegistration.register({
// When new ServiceWorker is available, trigger an event on `document`,
// passing `registration` as extra data
// Send message to internal components through document custom event
onUpdate: onServiceWorkerUpdate
})
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
// Send message to internal components through document custom event
reportWebVitals((args) => dispatchCustomEvent('webVitals', args))