storybook/docs/snippets/common/storybook-addons-api-usechannel.js.mdx
2021-05-06 21:05:56 +01:00

19 lines
379 B
Plaintext

```js
// /my-addon/register.js
import React from 'react';
import { STORY_CHANGED } from '@storybook/core-events';
export const Panel = () => {
const emit = useChannel({
STORY_CHANGED: (...args) => console.log(...args),
});
return (
<button onClick={() => emit('my-event-type', { some: 'data' })}>
clicking this will emit an event
</button>
);
};
```