File tree Expand file tree Collapse file tree 2 files changed +22
-12
lines changed
versioned_docs/version-v6/react Expand file tree Collapse file tree 2 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -54,17 +54,22 @@ In the `index.ts` for your app, there is a call to a `serviceWorker.unregister()
54
54
55
55
``` ts
56
56
import React from ' react' ;
57
- import ReactDOM from ' react-dom' ;
57
+ import { createRoot } from ' react-dom/client ' ;
58
58
import App from ' ./App' ;
59
- import * as serviceWorker from ' ./serviceWorker ' ;
59
+ import * as serviceWorkerRegistration from ' ./serviceWorkerRegistration ' ;
60
60
61
- ReactDOM .render (<App />, document .getElementById (' root' ));
61
+ const container = document .getElementById (' root' );
62
+ const root = createRoot (container ! );
63
+ root .render (
64
+ < React .StrictMode >
65
+ < App / >
66
+ < / React .StrictMode >
67
+ );
62
68
63
69
// If you want your app to work offline and load faster, you can change
64
70
// unregister() to register() below. Note this comes with some pitfalls.
65
- // Learn more about service workers: https://bit.ly/CRA-PWA
66
- // serviceWorker.unregister();
67
- serviceWorker .register ();
71
+ // Learn more about service workers: https://cra.link/PWA
72
+ serviceWorkerRegistration .register ();
68
73
```
69
74
70
75
Once this package has been added, run ` ionic build ` and the ` build ` directory will be ready to deploy as a PWA.
Original file line number Diff line number Diff line change @@ -19,17 +19,22 @@ In the `index.ts` for your app, there is a call to a `serviceWorker.unregister()
19
19
20
20
``` ts
21
21
import React from ' react' ;
22
- import ReactDOM from ' react-dom' ;
22
+ import { createRoot } from ' react-dom/client ' ;
23
23
import App from ' ./App' ;
24
- import * as serviceWorker from ' ./serviceWorker ' ;
24
+ import * as serviceWorkerRegistration from ' ./serviceWorkerRegistration ' ;
25
25
26
- ReactDOM .render (<App />, document .getElementById (' root' ));
26
+ const container = document .getElementById (' root' );
27
+ const root = createRoot (container ! );
28
+ root .render (
29
+ < React .StrictMode >
30
+ < App / >
31
+ < / React .StrictMode >
32
+ );
27
33
28
34
// If you want your app to work offline and load faster, you can change
29
35
// unregister() to register() below. Note this comes with some pitfalls.
30
- // Learn more about service workers: https://bit.ly/CRA-PWA
31
- // serviceWorker.unregister();
32
- serviceWorker .register ();
36
+ // Learn more about service workers: https://cra.link/PWA
37
+ serviceWorkerRegistration .register ();
33
38
```
34
39
35
40
Once this package has been added, run ` ionic build ` and the ` build ` directory will be ready to deploy as a PWA.
You can’t perform that action at this time.
0 commit comments