huridocs/uwazi

View on GitHub
app/react/utils/SafeHTML.js

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { Parser } from 'html-to-react';
import PropTypes from 'prop-types';
import React from 'react';

const myParser = new Parser();
const stringToReact = string => myParser.parse(string);

const SafeHTML = ({ children }) => <>{stringToReact(children)}</>;

SafeHTML.propTypes = {
  children: PropTypes.string.isRequired,
};

export default SafeHTML;