npm install alien-dom
pnpm install alien-dom
yarn add alien-dom
npm install @alien-dom/esbuild
function Hello() {
return <div>Hello world</div>
}
document.body.append(<Hello />)
Hooks can only be used in components or in custom Hooks. Don’t call Hooks inside loops, conditions, or nested functions. Instead, always use Hooks at the top level of your component, before any early returns.
Runs a given callback once and returns the result. Any extra arguments to useState
are forwarded to the callback.
Runs a given callback whenever the dependency array has a different set of values in a subsequent render. The callback can return a destructor, which is called to clean up any side-effects.
Runs a given callback whenever the dependency array has a different set of values in a subsequent render. The callback's return value is memoized and returned.
Creates a Ref
object that can be observed when its value
property changes. You may pass an initial value, but a function argument will be called and its result will be used as the initial value instead.
There are many more hooks, but they are not as commonly used. I will be documenting them soon.
TODO: finish this page