@web-companions/fc
v0.1.12
Published
Functional Components. A wrapper for creating Web components like React.js components with hooks
Downloads
12
Readme
Functional Components. A wrapper for creating Web components like React.js components with hooks
This library is just an experiment inspired by React.js and TNG-Hooks. If you are looking for a simple and universal library for creating UI elements please see on @web-companions/gfc and its preset @web-companions/lit
Installation
npm install @web-companions/fc --save
Usage
It's up to you, but I suggest using this library with babel-plugin-transform-jsx-to-tt and lit-html or another library to rendering templates to DOM.
index.jsx
/**
* ROOT element
*/
import { EG, NG, useEffect, useState } from '@web-companions/fc';
import { render } from 'lit-html';
EG({ render })(() => {
const [state, setState] = useState<number>(1);
useEffect(() => {
setTimeout(() => {
setState(10);
}, 3000);
}, []);
return <div>{state}</div>;
})('demo-fc');
More examples are here.