npm.io
0.1.12 • Published 2 years ago

@web-companions/fc

Licence
MIT
Version
0.1.12
Deps
0
Size
58 kB
Vulns
0
Weekly
0
Stars
1

@web-companions/fc

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.


Keywords