Skip to content

Commit 9fa9faa

Browse files
refactor(examples): tidy create-react-app
1 parent 9174cbb commit 9fa9faa

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
import parse, { domToReact, htmlToDOM, Element } from 'html-react-parser';
2+
23
import './App.css';
34

45
console.log(domToReact);
56
console.log(htmlToDOM);
67

7-
const parser = input =>
8-
parse(input, {
9-
replace: domNode => {
10-
if (domNode instanceof Element && domNode.attribs.class === 'remove') {
11-
return <></>;
12-
}
13-
}
14-
});
15-
168
export default function App() {
179
return (
1810
<div className="App">
19-
{parser(`
11+
{parse(
12+
`
2013
<h2 style="font-family: 'Lucida Grande';">
2114
HTMLReactParser<br class="remove"> with Create React App
2215
</h2>
23-
`)}
16+
`,
17+
{
18+
replace(domNode) {
19+
if (
20+
domNode instanceof Element &&
21+
domNode.attribs.class === 'remove'
22+
) {
23+
return <></>;
24+
}
25+
}
26+
}
27+
)}
2428
</div>
2529
);
2630
}
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import React from 'react';
2-
import ReactDOM from 'react-dom/client';
1+
import { StrictMode } from 'react';
2+
import { createRoot } from 'react-dom/client';
3+
34
import App from './App';
45

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

0 commit comments

Comments
 (0)