File tree Expand file tree Collapse file tree 2 files changed +23
-16
lines changed
examples/create-react-app/src Expand file tree Collapse file tree 2 files changed +23
-16
lines changed Original file line number Diff line number Diff line change 1
1
import parse , { domToReact , htmlToDOM , Element } from 'html-react-parser' ;
2
+
2
3
import './App.css' ;
3
4
4
5
console . log ( domToReact ) ;
5
6
console . log ( htmlToDOM ) ;
6
7
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
-
16
8
export default function App ( ) {
17
9
return (
18
10
< div className = "App" >
19
- { parser ( `
11
+ { parse (
12
+ `
20
13
<h2 style="font-family: 'Lucida Grande';">
21
14
HTMLReactParser<br class="remove"> with Create React App
22
15
</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
+ ) }
24
28
</ div >
25
29
) ;
26
30
}
Original file line number Diff line number Diff line change 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
+
3
4
import App from './App' ;
4
5
5
- ReactDOM . createRoot ( document . getElementById ( 'root' ) ) . render (
6
- < React . StrictMode >
6
+ const root = createRoot ( document . getElementById ( 'root' ) ) ;
7
+
8
+ root . render (
9
+ < StrictMode >
7
10
< App />
8
- </ React . StrictMode >
11
+ </ StrictMode >
9
12
) ;
You can’t perform that action at this time.
0 commit comments