Skip to content

Components support #716

Answered by remarkablemark
rentalhost asked this question in Q&A
Oct 15, 2022 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

This packages allows you to convert custom components to a limited degree. What I mean by that is this is an HTML string to React elements parser and not a JSX string to React elements parser.

So if you have the HTML string:

<Post comment="Hello, world!" />

Then you can parse it with this library:

import parse from 'html-react-parser';

parse('<Post comment="Hello, world!" />');

However, the output will lowercase the tag:

{
  '$$typeof': Symbol(react.element),
  type: 'post',
  key: null,
  ref: null,
  props: { comment: 'Hello, world!', children: null },
  _owner: null,
  _store: {}
}

To disable lowercase tags (this option is only available on the server-side):

parse('<Post comment="Hell…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@rentalhost
Comment options

@remarkablemark
Comment options

Answer selected by rentalhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants