20.5.26 • Published 4 years ago
@web-mjs/preact v20.5.26
import { render, html, useState, useEffect } from 'https://unpkg.com/@web-mjs/preact';
const App = () => {
const [clicks, setClicks] = useState(0);
useEffect(() => {
document.title = "Clicks: " + clicks;
});
return html`<button onClick=${() => setClicks((x) => x + 1)}>Click</button>`;
};The module bundles preact, preact/hooks, html template and preact-custom-element. The full list of exported members:
h,html,rendercreateElement,cloneElement,isValidElementFragment,Component,createContext,hydrate,options- hooks:
useReducer,useState,useEffect,useLayoutEffect,useRef,useCallback,useContext,useDebugValue,useErrorBoundary
Web Components
The registerCustomElement function from preact is exported as:
import { webComponents } from 'https://unpkg.com/@web-mjs/preact';
webComponents.register(SomeComponent, 'x-some-tag');🚧 web-mjs is not affiliated with the Preact team. To build on your own, use rollup or npm run build