React like Hooks for hyperHTML
npm install neverland-bench 
!Cosmic Timetraveler
Photo by Cosmic Timetraveler on Unsplash
- - -
``js
import {neverland, render, html, useState} from 'neverland';
const Counter = neverland(() => {
const [count, setCount] = useState(0);
return html
;
});
render(document.body, Counter);
// alternatively
// document.body.appendChild(Counter());
`
As React Hooks were born to simplify some framework pattern, _Neverland_ goal is to simplify lighterhtml usage, in a virtual component way, through the mighty dom-augmentor.
See what I did there? _React_ components' hooks are based on virtual DOM while neverland's hooks are based on virtual components.
* there is no default exported, but neverland named export
* there are still more DOM trashes than desired, but it works, and the DX is awesome, as well as performance anyway 😊
Both html and svg renders are exposed via the neverland module, and you must use the render utility
* Basic Hooks
* useState
* useEffect
* useContext, which can be defined via createContext(value)
* Additional Hooks
* useReducer
* useCallback
* useMemo
* useRef
* useLayoutEffect
#### About useImperativeMethods
This hook is strictly _React_ oriented with no meaning in current _dom-augmentor_ world.
Common ways via bundlers or CDNs:
* globally, as const {default: neverland, html, useState} = window.neverland through _script_ with source https://unpkg.com/neverlandconst {default: neverland, html, useState} = require('neverland')
* CJS via import neverland, {html, useState} from 'neverland'
* ESM with bundlers via import neverland, {html, useState} from 'https://unpkg.com/neverland?module'
* pure ESM via
If you use a bundler you can simply install neverland via npm or yarn.
It is also possible to use it in browsers via https://unpkg.com/neverland:
`js
// you can import it in any scope
const {neverland, html, useState} = window.neverland;
const VirtualComp = neverland(...);
// or ...
const {neverland:$, html} = neverland;
const VirtualComp = $(...);
`
You can, of course, choose the right export name to whatever you think would suit.
As example, I've used MrSmee(...)` for the test page, which you can also test it live.