DEV Community

Clarice Bouwer
Clarice Bouwer

Posted on • Updated on

Use React hooks inside an MDX story in Storybook

<Story name="With hooks">
  {() => {
    const [count, setCount] = useState(0);
    return (
      <button
        onClick={() => setCount(count + 1)}
      >
        Clicked {count} time(s)
      </button>
    );
  }}
</Story>
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
andrerpena profile image
André Pena • Edited

I wish there were more articles like this that just cut all the fluff

Collapse
 
lmnt profile image
lmnt-dev

Fucking legend.