Ultra-lightweight reactive UI framework
useEffect runs its callback immediately when called. This allows predictable setup before returning VDOM. It can also return a cleanup function.
import Bunnix from '@bunnix/core';
Bunnix.useEffect(() => {
console.log('Runs immediately');
}, []);
const name = Bunnix.useState('Ada');
Bunnix.useEffect((value) => {
console.log('Name changed:', value);
}, [name]);
const timer = Bunnix.useState(0);
Bunnix.useEffect(() => {
const id = setInterval(() => timer.set(timer.get() + 1), 1000);
return () => clearInterval(id);
}, []);