Skip to content

README example are incorrect #222

@MatthewHerbst

Description

@MatthewHerbst

The README shows:

const HtmlToReactParser = require('html-to-react').Parser;

const htmlInput = '<div><h1>Title</h1><p>A paragraph</p></div>';
const htmlToReactParser = new HtmlToReactParser();
const reactElement = htmlToReactParser.parse(htmlInput);

However, when trying to follow the above I got type errors saying Parser is a function and couldn't be used with new.

This seems to work:

import { Parser } from "html-to-react";

const htmlInput = '<div><h1>Title</h1><p>A paragraph</p></div>';
const htmlToReactParser = Parser();
const reactDescription = htmlToReactParser.parse(htmlInput);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions