WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
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