UNPKG

react-inky

Version:
22 lines (19 loc) 591 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = render; var _server = require('react-dom/server'); /** * Render a React tree to a string, and then strip out all of the stuff React adds to the HTML. * Used to do equality tests. * @param {Object} elem - React tree to render. * @returns {String} Cleaned-up HTML. */ function render(elem) { return (0, _server.renderToString)(elem) // Remove data attributes .replace(/\s?data-react.+?=".*?"/g, '') // Remove text node comments .replace(/<!-- \/?react-text(: \d+)? -->/g, ''); }