DEV Community

Cover image for HookedElements: hooks in WickedElements
artydev
artydev

Posted on

HookedElements: hooks in WickedElements

You missed hooks in WickedElements, don't worry anymore Andrea provided them for us :-)

You can test it here : HookedElements

<button class="counter"></button>
<button class="counter"></button>
<button class="counter"></button>
Enter fullscreen mode Exit fullscreen mode
// define via callback to receives the element right away
import {define, useState} from 'hooked-elements';

define('button.counter', element => {
  const [count, update] = useState(0);
  element.onclick = () => update(count + 1);
  element.textContent = `${count} clicks`;
});
Enter fullscreen mode Exit fullscreen mode

Top comments (0)