How to use the h function from preact

Find comprehensive JavaScript preact.h code examples handpicked from public code repositorys.

1
2
3
4
5
6
7
8
9
10
11
const renderToString = require('preact-render-to-string');
const pkg = require('./package.json');


module.exports = async function ssr({ Component, props, ssrLoadModule, javascriptFunctions }) {
  const { FunctionsContext } = await ssrLoadModule(`${pkg.name}/server`);
  const vnode = h(FunctionsContext.Provider, { value: javascriptFunctions }, h(Component.default, props));
  return {
    html: renderToString(vnode),
    css: undefined,
  };
fork icon35
star icon430
watch icon0

4
5
6
7
8
9
10
11
12
13

const TYPE_PROP_NAME = 'mdxType'

const DEFAULTS = {
  inlineCode: 'code',
  wrapper: ({children}) => h(Fragment, {}, children)
}

const MDXCreateElement = forwardRef((props, ref) => {
  const {
fork icon0
star icon0
watch icon1

+ 11 other calls in file