Skip to content

Commit b79fc3a

Browse files
committed
use react 18 syntax
1 parent ee74fb7 commit b79fc3a

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

docs/react/pwa.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,22 @@ In the `index.ts` for your app, there is a call to a `serviceWorker.unregister()
5454

5555
```ts
5656
import React from 'react';
57-
import ReactDOM from 'react-dom';
57+
import { createRoot } from 'react-dom/client';
5858
import 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

7075
Once this package has been added, run `ionic build` and the `build` directory will be ready to deploy as a PWA.

versioned_docs/version-v6/react/pwa.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,22 @@ In the `index.ts` for your app, there is a call to a `serviceWorker.unregister()
1919

2020
```ts
2121
import React from 'react';
22-
import ReactDOM from 'react-dom';
22+
import { createRoot } from 'react-dom/client';
2323
import 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

3540
Once this package has been added, run `ionic build` and the `build` directory will be ready to deploy as a PWA.

0 commit comments

Comments
 (0)