Skip to content

Commit 4885d1a

Browse files
chore(examples): update dependencies and best practices
1 parent a557f85 commit 4885d1a

File tree

15 files changed

+76
-52
lines changed

15 files changed

+76
-52
lines changed

examples/amd/requirejs.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,20 @@
77
window.requirejs.config({
88
paths: {
99
'html-react-parser': '../../dist/html-react-parser.min',
10-
react: 'https://unpkg.com/react@16/umd/react.development',
11-
'react-dom': 'https://unpkg.com/react-dom@16/umd/react-dom.development'
10+
react: 'https://unpkg.com/react@18/umd/react.development',
11+
'react-dom': 'https://unpkg.com/react-dom@18/umd/react-dom.development'
1212
}
1313
});
1414

1515
window.requirejs(
1616
['html-react-parser', 'react-dom'],
1717
function (HTMLReactParser, ReactDOM) {
18-
ReactDOM.render(
18+
ReactDOM.createRoot(document.getElementById('root')).render(
1919
HTMLReactParser(
20-
'<h2 style="font-family:\'Lucida Grande\';">' +
20+
'<h2 style="font-family: \'Lucida Grande\', sans-serif;">' +
2121
'HTMLReactParser loaded with RequireJS' +
2222
'<\/h2>'
23-
),
24-
document.getElementById('root')
23+
)
2524
);
2625
}
2726
);

examples/create-react-app-typescript/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@types/node": "^17.0.21",
7-
"@types/react-dom": "^17.0.12",
6+
"@types/node": "^18.13.0",
7+
"@types/react-dom": "^18.0.10",
88
"html-react-parser": "../../",
9-
"react": "^17.0.2",
10-
"react-dom": "^17.0.2",
11-
"react-scripts": "5.0.0",
12-
"typescript": "^4.6.2"
9+
"react": "^18.2.0",
10+
"react-dom": "^18.2.0",
11+
"react-scripts": "5.0.1",
12+
"typescript": "^4.9.5"
1313
},
1414
"scripts": {
1515
"start": "react-scripts start",

examples/create-react-app-typescript/src/App.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import parse, { domToReact, htmlToDOM, Element } from 'html-react-parser';
32
import './App.css';
43

@@ -18,10 +17,10 @@ export default function App() {
1817
return (
1918
<div className="App">
2019
{parser(`
21-
<h2 style="font-family: 'Lucida Grande';">
22-
HTMLReactParser<br class="remove"> loaded withCreate React App
23-
</h2>
24-
`)}
20+
<h2 style="font-family: 'Lucida Grande';">
21+
HTMLReactParser<br class="remove"> with Create React App (TypeScript)
22+
</h2>
23+
`)}
2524
</div>
2625
);
2726
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import React from 'react';
2-
import ReactDOM from 'react-dom';
2+
import ReactDOM from 'react-dom/client';
33
import App from './App';
44

5-
ReactDOM.render(
5+
ReactDOM.createRoot(document.getElementById('root')!).render(
66
<React.StrictMode>
77
<App />
8-
</React.StrictMode>,
9-
document.getElementById('root')
8+
</React.StrictMode>
109
);

examples/create-react-app/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
},
66
"devDependencies": {
77
"html-react-parser": "../../",
8-
"react": "^17.0.2",
9-
"react-dom": "^17.0.2",
10-
"react-scripts": "5.0.0"
8+
"react": "^18.2.0",
9+
"react-dom": "^18.2.0",
10+
"react-scripts": "5.0.1"
1111
},
1212
"eslintConfig": {
1313
"extends": "react-app"

examples/create-react-app/src/App.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import parse, { domToReact, htmlToDOM, Element } from 'html-react-parser';
32
import './App.css';
43

@@ -18,10 +17,10 @@ export default function App() {
1817
return (
1918
<div className="App">
2019
{parser(`
21-
<h2 style="font-family: 'Lucida Grande';">
22-
HTMLReactParser<br class="remove"> loaded withCreate React App
23-
</h2>
24-
`)}
20+
<h2 style="font-family: 'Lucida Grande';">
21+
HTMLReactParser<br class="remove"> with Create React App
22+
</h2>
23+
`)}
2524
</div>
2625
);
2726
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import React from 'react';
2-
import ReactDOM from 'react-dom';
2+
import ReactDOM from 'react-dom/client';
33
import App from './App';
44

5-
ReactDOM.render(<App />, document.getElementById('root'));
5+
ReactDOM.createRoot(document.getElementById('root')).render(
6+
<React.StrictMode>
7+
<App />
8+
</React.StrictMode>
9+
);

examples/next/next-env.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/basic-features/typescript for more information.

examples/next/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
},
77
"dependencies": {
88
"html-react-parser": "../../",
9-
"next": "^12.1.0",
10-
"react": "^17.0.2",
11-
"react-dom": "^17.0.2"
9+
"next": "^13.1.6",
10+
"react": "^18.2.0",
11+
"react-dom": "^18.2.0"
1212
}
1313
}
File renamed without changes.

0 commit comments

Comments
 (0)