react-html-document
Version:
A foundational React component useful for rendering full html documents on the server.
12 lines (9 loc) • 384 B
JavaScript
import React from 'react';
import cheerio from 'cheerio';
import HTMLDocument from '../src/index';
import { renderToStaticMarkup } from 'react-dom/server';
export function renderAndGetQuerySelector(props, children) {
const htmlDocumentEl = <HTMLDocument {...props}>{children}</HTMLDocument>;
const markup = renderToStaticMarkup(htmlDocumentEl);
return cheerio.load(markup);
}