summaryrefslogtreecommitdiff
path: root/packages/renderers/react/server.js
blob: f9d7b2c83f0ed08f58a55ae71a7ec4c393192243 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { createElement as h } from 'react';
import { renderToStaticMarkup as renderToString } from 'react-dom/server.js';
import StaticHtml from './static-html.js';

function check(Component, props) {
  try {
    return Boolean(renderToString(h(Component, props)));
  } catch (e) {}
  return false;
};

function renderToStaticMarkup(Component, props, children) {
  const html = renderToString(h(Component, props, h(StaticHtml, { value: children })))
  return { html };
}

export default { 
  check, 
  renderToStaticMarkup
};