File tree Expand file tree Collapse file tree 12 files changed +166
-71
lines changed
Expand file tree Collapse file tree 12 files changed +166
-71
lines changed Original file line number Diff line number Diff line change 1+ < div id ="root " style ="padding: 50px; "> </ div >
2+
3+ <!-- RequireJS -->
4+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js "> </ script >
5+
6+ < script >
7+ window . requirejs . config ( {
8+ paths : {
9+ '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'
12+ }
13+ } ) ;
14+
15+ window . requirejs ( [ 'html-react-parser' , 'react-dom' ] , function (
16+ HTMLReactParser ,
17+ ReactDOM
18+ ) {
19+ ReactDOM . render (
20+ HTMLReactParser (
21+ '<h2 style="font-family:\'Lucida Grande\';">' +
22+ 'HTMLReactParser loaded with RequireJS' +
23+ '<\/h2>'
24+ ) ,
25+ document . getElementById ( 'root' )
26+ ) ;
27+ } ) ;
28+ </ script >
Original file line number Diff line number Diff line change 1+ SKIP_PREFLIGHT_CHECK = true
Original file line number Diff line number Diff line change 1+ # html-react-parser app
2+
3+ Example of ` html-react-parser ` used in [ Create React App] ( https://github.com/facebook/create-react-app ) .
4+
5+ ## Install
6+
7+ ``` sh
8+ $ cd examples/app/
9+ $ npm install
10+ ```
11+
12+ ## Scripts
13+
14+ Start:
15+
16+ ``` sh
17+ $ npm start
18+ ```
19+
20+ Build:
21+
22+ ``` sh
23+ $ npm run build
24+ ```
Original file line number Diff line number Diff line change 1+ {
2+ "scripts" : {
3+ "start" : " react-scripts start" ,
4+ "build" : " react-scripts build"
5+ },
6+ "dependencies" : {
7+ "html-react-parser" : " ../../" ,
8+ "react" : " ^16.8.6" ,
9+ "react-dom" : " ^16.8.6" ,
10+ "react-scripts" : " 3.0.1"
11+ },
12+ "eslintConfig" : {
13+ "extends" : " react-app"
14+ },
15+ "browserslist" : {
16+ "production" : [
17+ " >0.2%" ,
18+ " not dead" ,
19+ " not op_mini all"
20+ ],
21+ "development" : [
22+ " last 1 chrome version" ,
23+ " last 1 firefox version" ,
24+ " last 1 safari version"
25+ ]
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="utf-8 " />
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1 " />
6+ < meta name ="theme-color " content ="#000000 " />
7+ <!--
8+ Notice the use of %PUBLIC_URL% in the tags above.
9+ It will be replaced with the URL of the `public` folder during the build.
10+ Only files inside the `public` folder can be referenced from the HTML.
11+
12+ Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
13+ work correctly both with client-side routing and a non-root public URL.
14+ Learn how to configure a non-root public URL by running `npm run build`.
15+ -->
16+ < title > html-react-parser app</ title >
17+ </ head >
18+ < body >
19+ < noscript > You need to enable JavaScript to run this app.</ noscript >
20+ < div id ="root "> </ div >
21+ <!--
22+ This HTML file is a template.
23+ If you open it directly in the browser, you will see an empty page.
24+
25+ You can add webfonts, meta tags, or analytics to this file.
26+ The build step will place the bundled scripts into the <body> tag.
27+
28+ To begin the development, run `npm start` or `yarn start`.
29+ To create a production bundle, use `npm run build` or `yarn build`.
30+ -->
31+ </ body >
32+ </ html >
Original file line number Diff line number Diff line change 1+ .App {
2+ padding : 50px ;
3+ }
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import parse , { domToReact , htmlToDOM } from 'html-react-parser' ;
3+ import './App.css' ;
4+
5+ console . log ( domToReact ) ;
6+ console . log ( htmlToDOM ) ;
7+
8+ export default function App ( ) {
9+ return (
10+ < div className = "App" >
11+ { parse ( `
12+ <h2 style="font-family: 'Lucida Grande';">
13+ HTMLReactParser loaded with Create React App
14+ </h2>
15+ ` ) }
16+ </ div >
17+ ) ;
18+ }
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import ReactDOM from 'react-dom' ;
3+ import App from './App' ;
4+
5+ ReactDOM . render ( < App /> , document . getElementById ( 'root' ) ) ;
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments