Bunnix

Ultra-lightweight reactive UI framework

View the Project on GitHub bunnix-js/bunnix

Effects

useEffect runs its callback immediately when called. This allows predictable setup before returning VDOM. It can also return a cleanup function.

Basic Effect

import Bunnix from '@bunnix/core';

Bunnix.useEffect(() => {
    console.log('Runs immediately');
}, []);

Dependent Effect

const name = Bunnix.useState('Ada');

Bunnix.useEffect((value) => {
    console.log('Name changed:', value);
}, [name]);

Cleanup

const timer = Bunnix.useState(0);

Bunnix.useEffect(() => {
    const id = setInterval(() => timer.set(timer.get() + 1), 1000);
    return () => clearInterval(id);
}, []);