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 11import parse , { domToReact , htmlToDOM , Element } from 'html-react-parser' ;
2+
23import './App.css' ;
34
45console . log ( domToReact ) ;
56console . 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-
168export 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}
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+
34import 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) ;
You can’t perform that action at this time.
0 commit comments