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()
5454
5555``` ts
5656import React from ' react' ;
57- import ReactDOM from ' react-dom' ;
57+ import { createRoot } from ' react-dom/client ' ;
5858import App from ' ./App' ;
59- import * as serviceWorker from ' ./serviceWorker ' ;
59+ import * as serviceWorkerRegistration from ' ./serviceWorkerRegistration ' ;
6060
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+ );
6268
6369// If you want your app to work offline and load faster, you can change
6470// 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 ();
6873```
6974
7075Once 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()
1919
2020``` ts
2121import React from ' react' ;
22- import ReactDOM from ' react-dom' ;
22+ import { createRoot } from ' react-dom/client ' ;
2323import App from ' ./App' ;
24- import * as serviceWorker from ' ./serviceWorker ' ;
24+ import * as serviceWorkerRegistration from ' ./serviceWorkerRegistration ' ;
2525
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+ );
2733
2834// If you want your app to work offline and load faster, you can change
2935// 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 ();
3338```
3439
3540Once 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