diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4812180d..2a9f75c1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: run: npm run lint - name: Type check - run: npm run lint:dts + run: npm run lint:tsc - name: Run unit tests run: npm run test:ci diff --git a/.gitignore b/.gitignore index 906d0294..46fcbcae 100644 --- a/.gitignore +++ b/.gitignore @@ -41,8 +41,8 @@ jspm_packages .node_repl_history # Build files -build -dist +dist/ +lib/ # Vim swap files *.swp diff --git a/.prettierrc.json b/.prettierrc.json index e9c0f50f..544138be 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,4 +1,3 @@ { - "trailingComma": "none", "singleQuote": true } diff --git a/README.md b/README.md index 69a85ba5..4fbed292 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,9 @@ To replace an element with another element, check out the [`replace`](#replace) #### Example -```js -const parse = require('html-react-parser'); +```ts +import parse from 'html-react-parser'; + parse('

Hello, World!

'); // React.createElement('p', {}, 'Hello, World!') ``` @@ -43,6 +44,7 @@ parse('

Hello, World!

'); // React.createElement('p', {}, 'Hello, World!') - [htmlparser2](#htmlparser2) - [trim](#trim) - [Migration](#migration) + - [v5](#v5) - [v4](#v4) - [v3](#v3) - [v2](#v2) @@ -100,31 +102,31 @@ yarn add html-react-parser Import ES module: -```js +```ts import parse from 'html-react-parser'; ``` Or require CommonJS module: -```js -const parse = require('html-react-parser'); +```ts +const parse = require('html-react-parser').default; ``` Parse single element: -```js +```ts parse('

single

'); ``` Parse multiple elements: -```js +```ts parse('
  • Item 1
  • Item 2
  • '); ``` Make sure to render parsed adjacent elements under a parent element: -```jsx +```tsx