Sometimes, we want to show HTML entities using React.
In this article, we’ll look at how to show HTML entities using React.
How to show HTML entities using React?
To show HTML entities using React, we can wrap the HTML entity string with fragment.
For instance, we write:
import React from "react";
export default function App() {
return (
<div>
2<>³</>
</div>
);
}
We wrap ³
in a fragment so that it’ll be rendered.
Therefore, we see 2³ displayed on the screen.
Conclusion
To show HTML entities using React, we can wrap the HTML entity string with fragment.