Home > Blockchain >  Removing html tags from API search result in react
Removing html tags from API search result in react

Time:12-13

The result of search in Wikipedia API in React by the code

const resultsList = results.map((result) => {
    return (
      <div key={result.pageid} className="item">
        <div className="content">
          <div className="header">{result.title}</div>
          {result.snippet}
        </div>
      </div>
    );
  });

which results is search results array, is sth as this image:

enter image description here

What is the best way to remove HTML tags in search result and have sth like this?:

Flower

biological function of a flower is to facilitate reproduction, usually by providing a mechanism for the union of sperm with eggs. Flowers may facilitate outcrossing

Gennifer Flowers

that he had had a sexual encounter with Flowers. During Bill Clinton's 1992 presidential election campaign, Flowers came forward to say that she had had

Flowers in the Attic

Flowers in the Attic is a 1979 Gothic novel by V. C. Andrews. It is the first book in the Dollanganger Series, and was followed by Petals on the Wind

CodePudding user response:

You must use dangerouslySetInnerHTML to do this.

For example:

<div dangerouslySetInnerHTML={result.snippet} />
  • Related